【问题标题】:Notification icon doesn't show in status bar in lollipop通知图标不显示在棒棒糖的状态栏中
【发布时间】:2014-12-27 17:24:36
【问题描述】:

这是我用来显示通知的代码。

notification = new Notification.Builder(context).setContentIntent(contentIntentTwo)
                        .setContentTitle("App name").setSmallIcon(R.drawable.ic_launcher).setLargeIcon(notificationLargeIconBitmap).getNotification();

通知和通知图标显示在下拉通知抽屉中,但不在棒棒糖的状态栏中。

这是棒棒糖中的样子:

这只发生在棒棒糖上。

【问题讨论】:

标签: android android-notifications


【解决方案1】:

【讨论】:

  • 那么,我只需要setcolor()?你能说得更详细一点吗?我刚刚阅读了文档,我可以从中得出的唯一结论是使用 setcolor
  • "系统会忽略操作图标和主通知图标中的所有非 alpha 通道。您应该假设这些图标将是 alpha-only。系统将通知图标绘制为白色,操作图标绘制为白色深灰色。”
  • 我刚刚说我阅读了文档。我的问题仍然存在。
  • @Rat-a-tat-a-tat Ratatouille 你不能。 Lollipop 将用白色覆盖层掩盖它。您的图标应该具有独特的形状。
【解决方案2】:

对于棒棒糖之前的版本,您仍然可以使用可绘制图像。但对于棒棒糖及更高版本,您需要透明背景图像用于通知图标(首选 png)。据我所知,棒棒糖版本或更高版本会将任何不透明的颜色转换为白色通知图标,因为它的简单性和“减少肤色”的想法可以达到材料设计。

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setContentTitle(title)
            .setContentText(body)
            .setPriority(2)
            .setContentIntent(pendingIntent);
    mBuilder.setAutoCancel(true);
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        mBuilder.setSmallIcon(R.mipmap.ic_launcher_transparant);
    }else{
        mBuilder.setSmallIcon(R.mipmap.ic_launcher);
    }

https://medium.com/swarm-nyc/complexion-reduction-a-new-trend-in-mobile-design-cef033a0b978#.fblfw0ohi

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多