Android: 如何调整通知范围内NotificationCompat.Builder的largeIcon
Android: How to adjust the largeIcon of a NotificationCompat.Builder in the bounds of the notification
我建立了一个通知,但是当我设置大图标时,它不适合边界。我会将其设置为按预期显示。
这是创建通知的代码:
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(image)
.setContentTitle(appName)
.setContentText(message)
.setSound(defaultSoundUri)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(pendingIntent);
尝试使用自定义布局来显示通知:
这可能对您有所帮助:
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
RemoteViews contentView = new RemoteViews(pkgName, R.layout.custom_notification);
contentView.setImageViewResource(R.id.notification_image, appIcon);
contentView.setTextViewText(R.id.notification_text, message);
notification.contentView = contentView;
我建立了一个通知,但是当我设置大图标时,它不适合边界。我会将其设置为按预期显示。
这是创建通知的代码:
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(image)
.setContentTitle(appName)
.setContentText(message)
.setSound(defaultSoundUri)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(pendingIntent);
尝试使用自定义布局来显示通知:
这可能对您有所帮助:
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
RemoteViews contentView = new RemoteViews(pkgName, R.layout.custom_notification);
contentView.setImageViewResource(R.id.notification_image, appIcon);
contentView.setTextViewText(R.id.notification_text, message);
notification.contentView = contentView;