2016-11-03 10 views
4

今日は通知アイコンに奇妙な問題があります。Androidの通知アイコンは白い円です

それは次のようになります。 enter image description here は(白丸...)

私は悪い何かをしましたか?ここで

Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) 
       .setSmallIcon(R.drawable.icon_notification) 
       .setContentTitle(this.getString(R.string.notification_title)) 
       .setContentText(this.getString(R.string.notification_text)) 
       .setAutoCancel(true) 
       .setSound(defaultSoundUri) 
       .setContentIntent(pendingIntent); 

は私のアイコン画像(たて https://material.io/icons/#ic_photoここからダウンロード)されています http://image.noelshack.com/fichiers/2016/44/1478185219-icon-notification.png

は、私が何かを逃しましたか?

私はSDK24を使用しており、現在はhdpiリソースフォルダのみを作成しています。

編集#1:私は

編集#2 ...何も変更、ldpimdpixhdpiアイコンを追加しました:より精度のために、私はサービスからこの通知を作成しようとしています。.. FCMメッセージングサービス...

答えて

2

(完全に色の)私が使っていた最初のイメージが悪かった...コンパイル時にキャッシュの問題のようですので、私は私のcompilatorが上のキャッシュのsomekindを作成したと思いますファイル名。

私はWindowsで動作し、これを行いました:私の電話からアプリをアンインストールし、Android sudioからすべてのキャッシュを無効にする=>再コンパイル時にアイコンはOKです。

2

背景のない通知アイコンを使用する必要があります。 Androidのサークルの背景が追加されます。

あなたはアプリのindentityに一致するように

.setColor(context.getResources().getColor(R.color.colorPrimary))

と背景色を設定することができます。

アイコンの内側は白のままで、サークルは定義した色を取得します。

On Android Studio On system bar On notification

+0

ありがとう:アイコンを設定し

uは、この

private int getSmallIconForNotification(){ return (Build.VERSION.SDK_INT>Build.VERSION_CODES.LOLLIPOP)? R.mipmap.ic_stat_launcher : R.mipmap.ic_launcher; } 

コードの使用のようなメソッドを持つことができます!あなたは私に何かを学んだ!しかし、これはトリックをしなかった:/ – PoulsQ

1

compileSDKversionが20を超える場合、通知アイコンは透明な背景イメージになります。それ以外の場合、画像は白色の画像としてレンダリングされます。

アイコン

https://www.google.com/design/spec/patterns/notifications.html

とも通知アイコンジェネレータを作成するためのガイドラインについては、あまりにも、下のリンクを経由してください。

https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.space.trim=1&source.space.pad=0&name=ic_stat_example

0

注: - デバイスは、20以上のAndroidバージョンを持っている場合は、透明な背景を持つアイコンを生成しており、

int currentapiVersion = android.os.Build.VERSION.SDK_INT; 
if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP){ 
     currentapiVersion=R.mipmap.ic_notification_lolipop; 
} else{ 
     currentapiVersion=R.mipmap.ic_launcher; 
} 

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) 
      .setSmallIcon(currentapiVersion)...... 
0

通知用にこのスニペットを生成しながらUが生成され、別のアイコンを持っている必要がありますランチャーアイコンの白いバージョンになります。 Uはそのようなアイコンを生成するために以下のリンクを使用することができます。

https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=clipart&source.clipart=ac_unit&source.space.trim=1&source.space.pad=0&name=ic_stat_ac_unit

注:透明な背景を持つあなたのランチャーアイコンのPNG画像をアップロードする必要があります。

private NotificationCompat.Builder createNotificationBuilder(){ 
    return new NotificationCompat.Builder(this) 
      .setSmallIcon(getSmallIconForNotification()) 
      .setContentTitle("New Message") 
      .setContentText("Hi there.....") 
      .setAutoCancel(true); 
} 
関連する問題