My activity_main.xml
is below, as you see, the height is set 40 dip.
And in MyEclipse, it looks like below:
But when I run it on my phone, it looks like below:
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?
This is the progress bar I have used.
<ProgressBar android:padding="@dimen/dimen_5" android:layout_below="@+id/txt_chklist_progress" android:id="@+id/pb_media_progress" style="@style/MyProgressBar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:progress="70" android:scaleY="5" android:max="100" android:progressBackgroundTint="@color/white" android:progressTint="@color/green_above_avg" />
And this is my style tag
As mentioned in other answers, it looks like you are setting the style of your progress bar to use Holo.Light:
If this is running on your phone, its probably a 3.0+ device. However your emulator looks like its using a "default" progress bar.
Perhaps you changed the style to the "default" progress bar in between creating the screen captures? Unfortunately 2.x devices won't automatically default back to the "default" progress bar if your projects uses a Holo.Light progress bar. It will just crash.
If you truly are using the default progress bar then setting the max/min height as suggested will work fine. However, if you are using the Holo.Light (or Holo) bar then setting the max/min height will not work. Here is a sample output from setting max/min height to 25 and 100 dip:
max/min set to 25 dip:
max/min set to 100 dip:
You can see that the underlying drawable (progress_primary_holo_light.9.png) isn't scaling as you'd expect. The reason for this is that the 9-patch border is only scaling the top and bottom few pixels:
The horizontal area bordered by the single-pixel, black border (green arrows) is the part that gets stretched when Android needs to resize the .png vertically. The area in between the two red arrows won't get stretched vertically.
The best solution to fix this is to change the 9patch .png's to stretch the bar and not the "canvas area" and then create a custom progress bar xml to use these 9patches. Similarly described here: https://stackoverflow.com/a/18832349
Here is my implementation for just a non-indeterminant Holo.Light ProgressBar. You'll have to add your own 9-patches for indeterminant and Holo ProgressBars. Ideally I should have removed the canvas area entirely. Instead I left it but set the "bar" area stretchable. https://github.com/tir38/ScalingHoloProgressBar