Search code examples
androidnotificationsandroid-notificationsremoteview

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?


Solution

  • 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 #3333B5E5 and those dimensions are just 64dp. 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!