答案 0 :(得分:13)
BigPictureStyle的通知图片大小
最低 - 512x256
平衡 - 1024x512
最大值 - 2048x1024
得到了这个答案https://stackoverflow.com/a/33391039/5783417
注意:在较小的设备(800x480)中,仍有中心裁剪 发生
答案 1 :(得分:0)
试试此代码
Notification notif = new Notification.Builder(mContext)
.setContentTitle("New photo from " + sender.toString())
.setContentText(subject)
.setSmallIcon(R.drawable.new_post)
.setLargeIcon(aBitmap)
.setStyle(new Notification.BigPictureStyle()
.bigPicture(aBigBitmap))
.build();
答案 2 :(得分:-1)
要在展开视图中显示通知,请首先使用所需的常规视图选项创建NotificationCompat.Builder对象。接下来,使用展开的布局对象作为参数调用Builder.setStyle()。
请记住,在Android 4.1之前的平台上无法使用扩展通知。要了解如何处理Android 4.1和早期平台的通知,请阅读处理兼容性部分。
例如,以下代码段演示了如何更改在上一个代码段中创建的通知以使用展开的布局:
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle("Event tracker")
.setContentText("Events received")
NotificationCompat.InboxStyle inboxStyle =
new NotificationCompat.InboxStyle();
String[] events = new String[6];
// Sets a title for the Inbox in expanded layout
inboxStyle.setBigContentTitle("Event tracker details:");
...
// Moves events into the expanded layout
for (int i=0; i < events.length; i++) {
inboxStyle.addLine(events[i]);
}
// Moves the expanded layout object into the notification object.
mBuilder.setStyle(inboxStyle);
...
// Issue the notification here.