无法在 RemoteViews 上设置ProgressDrawable
我正在尝试在 RemoteViews
中的 ProgressBar
上调用 setProgressDrawable
但是,我尝试过 RemoveViews
上似乎没有 setDrawable(
方法setBitmap 但 setProgressDrawable
采用 Drawable
而不是 Bitmap
和 setInt
也不行。
我想避免仅仅为了处理不同颜色的进度条而加载不同的小部件布局 xml 文件。
I'm trying to call setProgressDrawable
on a ProgressBar
in my RemoteViews
However there doesn't appear to be a setDrawable(<view_id>,<method>,<value>)
method on RemoveViews
I've tried setBitmap
but setProgressDrawable
takes a Drawable
not a Bitmap
and setInt
doesn't work either.
I wanted to avoid having loads of different widget layout xml files just to handle different color progress bars.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有办法做到这一点。我的解决方案不是创建单独的布局文件,而是创建包含具有不同 ProgressDrawables 的所有不同 ProgressBar 的布局文件。在代码中,您只需使其中之一可见。
请注意,对于较旧的 Android 版本,不允许直接在进度条上调用 setViewVisibility。诀窍是在每个栏周围包装一个简单的 LinearLayout 并使该包装器不可见/可见。对我来说效果很好。
There is no way to do this. My solution was not to create separate layout files, but one that contains all the different ProgressBars with different progressDrawables. In the code you then have to make only one of them visible.
Please note that for older android versions it is not allowed to call setViewVisibility on the Progressbar directly. The trick is to wrap a simple LinearLayout around each bar and to make this wrapper invisible/visible instead. Works fine for me.