How to set the Android progressbar's height?

2019-01-17 02:05发布

My activity_main.xml is below, as you see, the height is set 40 dip.

And in MyEclipse, it looks like below:

enter image description here

But when I run it on my phone, it looks like below:

enter image description here

So my question is why the real height of the progressbar is not the one I set? How to increase the height of the progressbar?

8条回答
仙女界的扛把子
2楼-- · 2019-01-17 02:53
<ProgressBar  
android:minHeight="20dip" 
android:maxHeight="20dip"/>
查看更多
虎瘦雄心在
3楼-- · 2019-01-17 02:54

From this tutorial:

<style name="CustomProgressBarHorizontal" parent="android:Widget.ProgressBar.Horizontal">
      <item name="android:progressDrawable">@drawable/custom_progress_bar_horizontal</item>
      <item name="android:minHeight">10dip</item>
      <item name="android:maxHeight">20dip</item>
</style>

Then simply apply the style to your progress bars or better, override the default style in your theme to style all of your app's progress bars automatically.

The difference you are seeing in the screenshots is because the phones/emulators are using a difference Android version (latest is the theme from ICS (Holo), top is the original theme).

查看更多
别忘想泡老子
4楼-- · 2019-01-17 02:58

Use this

style="@android:style/Widget.ProgressBar.Horizontal"

查看更多
Evening l夕情丶
5楼-- · 2019-01-17 02:59

values->styles.xml

<style name="tallerBarStyle" parent="@android:style/Widget.SeekBar">
    <item name="android:indeterminateOnly">false</item>
    <item name="android:progressDrawable">@android:drawable/progress_horizontal</item>
    <item name="android:indeterminateDrawable">@android:drawable/progress_horizontal</item>
    <item name="android:minHeight">8dip</item>
    <item name="android:maxHeight">20dip</item>
</style>

Then in your ProgressBar add:

style="@style/tallerBarStyle"
查看更多
倾城 Initia
6楼-- · 2019-01-17 03:01

android:scaleY="8" in your xml file

查看更多
时光不老,我们不散
7楼-- · 2019-01-17 03:06

I guess the simplest solution would be:

mProgressBar.setScaleY(3f);
查看更多
登录 后发表回答