2016-07-05 18 views
0

Ich arbeite an der Benachrichtigung. Ich würde das Benachrichtigungssymbol mit dem folgenden Code festlegen, aber nicht die Hintergrundfarbe des Symbols (das abgerundete lila wie hervorgehoben) festlegen. Großartig, wenn jemand die Methode teilen würde.NotificationBuilder setSmallIcon "Hintergrund" Farbe

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

enter image description here

[Follow-up] Yum ... Ich habe die Methode versucht, wie in der Post, aber ... die Hintergrundfarbe des Symbols ist immer noch "weiß", schlug .. . ich die Farbe nicht ...

gesetzt würde

enter image description here

+0

Mögliches Duplikat [auf Lollipop Benachrichtigungssymbol Hintergrund Ändern] (http://stackoverflow.com/questions/27343202/changing-notification-icon-background-on-lollipop) –

+0

ich yr Ansatz versucht, aber den Hintergrund ist noch farblos. Irgendwelche Hinweise? –

Antwort

0

denke ich, dass ich auf diese Weise wird nicht empfohlen, prüfen, ein Symbol mit der Farbe, die Sie wünschen

1
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>