AppWidget:使用可绘制对象更新 ImageView?
我正在尝试创建一个具有可自定义背景的应用程序小部件。我使用 NinePatchDrawable,我想更改它的颜色(使用 setColorFilter 方法)。这在 Activity 中没有问题,但对于用于 appwidgets 的 RemoteView 对象来说似乎不可能。
有没有办法让应用程序小部件中的 ImageView 更新为新的 Drawable,而不是位图?
或者如果没有,也许可以获取应用程序小部件的实际大小并将彩色 NinePatchDrawable 转换/保存为位图,然后用它更新 ImageView ?
我已经搜索了很多解决方案,但到目前为止还没有找到任何东西。我希望这不是不可能的。 谢谢,
弗罗赫特
I'm trying to create an appwidget with a customizable background. I use a NinePatchDrawable and I would like to change it's color (using the setColorFilter method). This is no problem in an Activity, but it does dot seem possible with the RemoteView object used for appwidgets.
Is there some way to get an ImageView in an appwidget to be updated with a new Drawable, not a Bitmap?
Or if not, perhaps it's possible to get the actual size of the appwidget and convert / save the colored NinePatchDrawable to a Bitmap and then update the ImageView with that?
I already searched quite a bit for a solution, but haven't found anything so far. I hope it's not impossible.
Thanks,
Froghut
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
setImageViewResource()
并不意味着位图,但它必须是资源。不,抱歉。
不允许有无限范围的颜色。允许自定义少数颜色,并为其添加适当的资源。
setImageViewResource()
does not imply a bitmap, but it does have to be a resource.No, sorry.
Don't allow an infinite range of colors. Allow customization for a handful of colors for which you include appropriate resources.