Android:如何更改进度条的高度?
我想知道在 Android 中更改 ProgressBar 高度的最简单方法是什么?
谢谢,
托梅克
I was wondering what is the easiest way to change the height of a ProgressBar in Android?
Thanks,
Tomek
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您的进度条是在 XML 布局中定义的,那么您似乎是这样定义其高度的:
但是我只是从 本文。
If your progress bar is defined in the XML layout, it looks like you define its height like so:
However I'm just making a guess from this article.
您需要替换
为
,layout_height 才能工作
You need to replace
to
and layout_height will work
诀窍是让你的进度条使用“旧的”、无光环的样式。否则,它将使用 9 块图像作为进度可绘制对象,并且除非操作图像,否则无法更改高度。所以这就是我所做的:
进度条:
可绘制的进度(horizontal_progress_drawable_red.xml):
The trick is to have your ProgressBar use the "old", none halo, style. Otherwise it will use a 9-patch image as a progress drawable and you can't change the height unless you manipulate the image. So here is what I did :
the progressbar :
the progress drawable (horizontal_progress_drawable_red.xml) :
可以使用这段代码:
或者使用自定义样式
值->styles.xml
然后在你的ProgressBar中添加:
Can use this code :
Or use custom style
values->styles.xml
Then in your ProgressBar add: