3

I am using the Android progressbar in one of my widgets:

<ProgressBar
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/progressBarStyleHorizontal"
        android:id="@+id/progressbar_Horizontal"
        android:max="100"/>

In Android 2.x it looks well, like in the following picture. I have written the % on top of the bar itself.

ProgressBar in Android 2.x

But if I change in the Android Manifest

android:targetSdkVersion

to "15" the progressbar looks totaly different. It is now a thin blue line instead of a bar. The problem is that I have written above the progress bar some text, in particuallary % of the progress. Thus as the bar is so thin this looks odd.

I cannot figure out how to increase the height of the bar again to e.g. 50dp. If I try android:layout_height="50dp" it stays still same thin.

TZHX
  • 5,291
  • 15
  • 47
  • 56
tobias
  • 2,322
  • 3
  • 33
  • 53

2 Answers2

9

First, you need to define the style of your progress bar in values->styles.xml of your project. something like:

<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>

Edit the maxHeight to your desired height.

Then in your ProgressBar add:

style="@style/tallerBarStyle"
blackgreen
  • 34,072
  • 23
  • 111
  • 129
kdroider
  • 731
  • 5
  • 20
1

You need to replace

style=”?android:attr/progressBarStyleHorizontal”

to

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

and layout_height will work

android:layout_height="50dp"
rnofenko
  • 9,198
  • 2
  • 46
  • 56