如何在 Android Wear 通知上显示清晰的背景图片? [英] How to display clear background image on Android Wear notification?
问题描述
据我所知,有两种方法可以为 Android Wear 中的通知设置背景图像.为了记录,两者都以:
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)
...等等来设置通知.还假设 bitmap
已初始化为适当大小的图像(尽管这是另一个问题).
...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).
方法一:
bob.setLargeIcon(bitmap);
这有效,但 AFAICT bitmap
在通知的背景中总是模糊不清,无论其大小如何.
This works, but AFAICT bitmap
is always blurred-out in the background of the notification, regardless of its size.
方法二:
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?
推荐答案
请使用 WearableExtender
中的 setBackground(Bitmap)
方法而不是 setLargeIcon(Bitmap)代码>.它将设置不会模糊的背景位图.
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));
这篇关于如何在 Android Wear 通知上显示清晰的背景图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!