无法在 RemoteViews 上设置ProgressDrawable

发布于 2024-12-11 17:20:21 字数 394 浏览 5 评论 0原文

我正在尝试在 RemoteViews 中的 ProgressBar 上调用 setProgressDrawable
但是,我尝试过 RemoveViews 上似乎没有 setDrawable(,,) 方法setBitmap 但 setProgressDrawable 采用 Drawable 而不是 BitmapsetInt也不行。

我想避免仅仅为了处理不同颜色的进度条而加载不同的小部件布局 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雾里花 2024-12-18 17:20:21

没有办法做到这一点。我的解决方案不是创建单独的布局文件,而是创建包含具有不同 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文