1

I am working on the notification. I would set the notification icon using the code below but fail to set the background color of the icon (the rounded purple as highlighted). Great if anyone would share the method.

    notificationBuilder.setContentTitle(title);
    notificationBuilder.setContentText(summaryText);      
    notificationBuilder.setSmallIcon(R.drawable.icon);
    notificationBuilder.setContentIntent(clickIntent);
    notificationBuilder.setDeleteIntent(deleteIntent);

enter image description here

[Follow-up] Yum...I have tried the method as suggested in the post BUT... the background color of the icon is still "white"... I would not set the color...

enter image description here

Antoine Murion
  • 773
  • 1
  • 14
  • 26

2 Answers2

2
You can probably create drawable to set icon background and set that as icon 

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="@dimen/margin_10dp" android:left="@dimen/margin_10dp" android:top="@dimen/margin_10dp" android:bottom="@dimen/margin_10dp">
    <shape android:shape="rectangle">
        <solid android:color="@color/purple"/>
        <padding android:bottom="@dimen/margin_10dp" android:right="@dimen/margin_10dp" android:left="@dimen/margin_10dp" android:top="@dimen/margin_10dp"/>
    </shape>
</item>
    <item android:drawable="@mipmap/logo" >
    </item>

</layer-list>
Aditi
  • 455
  • 4
  • 13
0

I guess that is not recommended do that way, consider provide an icon with the color that you wish