繁体   English   中英

android通知栏(图标)显示不正确

[英]android notification bar (icon) show not correctly

我目前正在从事我的android音乐应用程序项目。 我正面临通知问题。

图片来源: http//postimg.org/image/enticjvjl/

请先打开链接,按下歌曲后,歌曲会正确播放,一切正常。 但是,在第一个图片中,左侧的图标未正确缩放,从而导致了问题。 在1秒钟内,通知图标正确显示,如我们在第二张图片中所见(带有黄色背景的第一个图标是我的应用程序)。

这是我用来创建通知栏的代码。

    Bitmap largeIcon;
    largeIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.launcher);
    int height = (int) this.getResources().getDimension(android.R.dimen.notification_large_icon_height);
    int width = (int) this.getResources().getDimension(android.R.dimen.notification_large_icon_width);
    largeIcon = Bitmap.createScaledBitmap(largeIcon, height, width, false);

    builder.setContentIntent(pendInt)
      .setSmallIcon(R.drawable.launcher)
      .setLargeIcon(largeIcon)
      .setTicker(songTitle)
      .setOngoing(true)
      .setWhen(System.currentTimeMillis())
      .setContentTitle("Playing")
      .setContentText(songTitle);
    Notification not = builder.build();

    startForeground(NOTIFY_ID, not);

我相信您的问题是您不缩放在setSmallIcon方法中设置的图标。 尝试设置与setLargeIcon方法相同的图标。 或反过来:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM