我想在 Android 通知栏中显示大图片样式图像。但我遇到了问题 -> 当我使用以下代码在通知栏中设置图像时:
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ctx)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(title)
.setContentText(message)
.setOngoing(false)
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(bitmap))
.setPriority(Notification.PRIORITY_HIGH)
//.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setContentIntent(resultPendingIntent);
// mId allows you to update the notification later on.
mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI);
mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
NotificationManager mNotificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(0 , mBuilder.build());
它总是从左角和右角裁剪。我不想使用远程视图来实现同样的目的。谁能告诉我可以放置在通知栏中且不应被裁剪的图像的大小和分辨率。
Thanks
之所以被裁剪是因为它不是 2:1 的比例
您为大图片提供的图像应采用 2:1 的比例,否则它会被裁剪,或者图像很小,它会被拉伸。
看一下这个https://documentation.onesignal.com/docs/android-customizations#section-big-picture
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)