且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android Nougat的通知中未显示图标

更新时间:2023-01-24 16:30:09

这不是错误,而是设计上的更改Android牛轧糖。设备不再显示由 addAction(Notification.Action操作) 定义的图标。还是旧设备和Android Wear设备仍需要它们!

This is not an error, but a change in the design with Android Nougat. Icons defined by addAction (Notification.Action action) are not any more displayed by devices. They still are required for older devices and Android Wear devices!

引用 Android开发人员Google博客


您会注意到图标未出现在新通知中;
会在通知阴影的
受限空间中为标签本身提供更多空间。但是,通知
操作图标仍然是必需的,并且会继续在较旧的
版本的Android和Android Wear等设备上使用。

You’ll note that the icons are not present in the new notifications; instead more room is provided for the labels themselves in the constrained space of the notification shade. However, the notification action icons are still required and continue to be used on older versions of Android and on devices such as Android Wear.

如果您一直使用
NotificationCompat.Builder和
可用的标准样式来构建通知,则默认情况下您将获得新的外观,而无需更改代码

If you’ve been building your notification with NotificationCompat.Builder and the standard styles available to you there, you’ll get the new look and feel by default with no code changes required.