简体   繁体   English

为什么 Android 通知图标 position 因设备/版本而异?

[英]Why Android notification icon position differs depending on device/version?

Seems Android is displaying notification icons in different places depending on OS or device.似乎 Android 根据操作系统或设备在不同的地方显示通知图标。

Usually it's on top left corner, but sometimes, it's left side but centred with text.通常它位于左上角,但有时它位于左侧但以文本为中心。 Does anybody know what is the logic behind it?有谁知道背后的逻辑是什么?

Examples:例子:

Centered Top left左上角居中

Seems it's not related to OS so much as I have seen both versions on same versions of Android. Maybe something else?似乎它与操作系统无关,因为我在 Android 的相同版本上看到了这两个版本。也许还有其他原因?

Different releases of Android have changed the UI styling for notifications - your first example is from Marshmallow (Android 6) or before, the other is what it looks like on modern versions of Android. And that's just for stock Android - almost every phone manufacturer adds their own tweaks to the UI to some degree, and if they decide to make changes to the standard layouts, they can! Android 的不同版本更改了通知的 UI 样式 - 您的第一个示例来自 Marshmallow(Android 6)或更早版本,另一个是现代版本 Android 的外观。这仅适用于库存 Android - 几乎每个手机制造商都添加他们自己在某种程度上调整了用户界面,如果他们决定对标准布局进行更改,他们可以!

If you want to create a notification, it's recommended you use the NotificationCompat support library .如果要创建通知,建议您使用NotificationCompat支持库 This allows you to configure the notification in different ways, so you get a few standard variations .这允许您以不同的方式配置通知,因此您可以获得一些标准变体 Using the support library means you can use configurations that weren't supported by the notification system on older OS versions, and they'll use safe fallbacks.使用支持库意味着您可以使用旧操作系统版本上的通知系统不支持的配置,并且它们将使用安全回退。

How those standard variations will actually appear depends on the device - for consistency, all notifications on a device will follow those standard templates.这些标准变体的实际显示方式取决于设备——为了保持一致性,设备上的所有通知都将遵循这些标准模板。 You wouldn't be able to get your modern example mixed in with the old Holo style, it would look weird because the styling is completely different.您将无法将现代示例与旧的 Holo 样式混合在一起,它看起来很奇怪,因为样式完全不同。

It's ultimately up to the OS to decide what notifications should look like, you just provide some attributes like different text labels, an image, media content, etc. and it decides what to do with them.最终由操作系统决定通知应该是什么样子,你只需提供一些属性,如不同的文本标签、图像、媒体内容等,它决定如何处理它们。 That's why the old style puts the icon in a big circle on the left, with the two bits of text displayed that way, and the newer version uses a small icon inline with the app name, etc.这就是为什么旧样式将图标放在左侧的大圆圈中,并以这种方式显示两位文本,而较新版本使用与应用程序名称内嵌的小图标等。


It is possible to create a custom notification , where you can basically define the whole content and have control over the UI, so you could have completely mismatched notification styles on the same device - but I don't think you'd see that much, since it would make your app look strange on devices where the UI doesn't match. 可以创建自定义通知,您基本上可以在其中定义全部内容并控制 UI,因此您可以在同一台设备上拥有完全不匹配的通知 styles - 但我认为您不会看到那么多,因为这会使您的应用在 UI 不匹配的设备上看起来很奇怪。 And like that link says, from Android 12 onwards you're only able to customise an area of the notification, which doesn't include the standard header (app icon and name, timestamp etc)就像那个链接所说的那样, 从 Android 12 开始,您只能自定义通知区域,其中不包括标准的 header(应用程序图标和名称、时间戳等)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 某些设备的Android通知白色图标显示 - Android notification white icon display for some device 如何在Android Lollipop版本上设置通知图标 - How to set notification icon on android lollipop version 根据上下文更改Android小通知图标颜色 - Change Android small notification icon color depending on context Android Notification和Alarmmanager - 时间不同 - Android Notification & Alarmmanager - Timing differs Android(视图):ListView中的子位置取决于Android版本 - Android (View): Child position inside ListView depending on android version 为什么变量会根据Android版本而变化? - Why does variables changes depending on android version? 如何使用 DELPHI 在 Android 设备上更改通知中的小图标图像 - How to change small icon image in notification on Android device with DELPHI Android 9+ 设备在提示通知中的应用程序上缺少图标 - Android 9+ device misses icon on application in heads-up notification 为什么GCM在Android设备中不给出推送通知? - why GCM is not giving push notification in android device? 通知 - 在Lollipop Android版本上设置大图标 - Notification - set large icon on pre Lollipop Android version
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM