Antoine Murion
Antoine Murion

Reputation: 813

NotificationBuilder setSmallIcon "background" color

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

Upvotes: 1

Views: 648

Answers (2)

Aditi
Aditi

Reputation: 455

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>

Upvotes: 2

Saulo Aires
Saulo Aires

Reputation: 76

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

Upvotes: 0

Related Questions