简体   繁体   中英

Android Notification icon on the left

Here's an odd question: How can I get the "styled" notification icon in the navigation drawer? Android (on my Nexus 5 at least) adds a little blue background to that icon, apparently. I would like to get that styled icon with its background.

What I really am getting at: I want to make a cool, custom expanded notification using RemoteViews. However, I want to keep that default, styled notification icon in the top left of my custom RemoteViews notification.

Any ideas?

Ah, haha! Got it!

https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/layout/notification_template_big_text.xml

<ImageView
    android:id="@+id/notifcation_icon"
    android:layout_width="@dimen/notification_large_icon_width"
    android:layout_height="@dimen/notification_large_icon_height"
    android:background="@android:drawable/notification_template_icon_bg"
    android:scaleType="center" />

By the way, that background is really just and those dimensions are just . 而这些尺寸仅为Please note that this is totally able to change depending on manufacturer, device, and Android version. Since these are not public resources, the best option is just to copy it over. Not great, but it will have to do.

I hope my digging into this helps someone!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM