Seems Android is displaying notification icons in different places depending on OS or device.
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:
Seems it's not related to OS so much as I have seen both versions on same versions of Android. Maybe something else?
CodePudding user response:
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!
If you want to create a notification, it's recommended you use the NotificationCompat
support library. 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.
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. 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)