How to display clear background image on Android Wear notification?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 04:54:13

问题


As far as I can work out, there are two ways to set the background image for a notification in Android Wear. For the record, both start with:

   Bitmap bitmap;
   Notification.Builder bob = new Notification.Builder(this)
            .setContentTitle(title)

...and so on to set up the notification. Also assume that bitmap has been initialized to an appropriately-sized image (though that's another issue).

Method 1:

   bob.setLargeIcon(bitmap);

This works, but AFAICT bitmap is always blurred-out in the background of the notification, regardless of its size.

Method 2:

   bob.setStyle(new Notification.BigPictureStyle().bigPicture(bitmap));

This clears up the bitmap, but has the unfortunate side effect of inserting an extra "page" on the wearable, a page that is blank except for the bitmap. I suppose the thinking here is that you're trying to show the image to the user - but I'm not, I just want a non-blurry background.

Is there a way to accomplish this?


回答1:


Please use setBackground(Bitmap) method from WearableExtender instead of setLargeIcon(Bitmap). It will set the background bitmap that won't be blurred.

Notification.Builder wearableBuilder = new Notification.Builder(context)
    ...
    .extend(new WearableExtender().setBackground(bitmap));


来源:https://stackoverflow.com/questions/24841329/how-to-display-clear-background-image-on-android-wear-notification

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!