views:

576

answers:

3

I have a progressbar with the following style: style="?android:attr/android:progressBarStyleSmall"

Sadly the bar is nearly white and in my case displayed on a white background. The progressbar is nearly invisible because of that.

How can I change the color of the progressbar? A darker grey would be great.

+1  A: 

I had a very hard time trying to change it's color. To solve it, I got android's src code and did my own ProgressBar class.

Not the best answer, but it worked for me.

Macarse
+3  A: 

The reason why the bar is of that color is because of the style you have selected. That is a fixed style and uses the system themes for the generation of UI elements.

Look at the source code from here. This progressBarStyleSmall attribute uses the styles defined here.

<style name="Widget.ProgressBar.Small">
    <item name="android:indeterminateDrawable">@android:drawable/progress_small_white</item>
    <item name="android:minWidth">16dip</item>
    <item name="android:maxWidth">16dip</item>
    <item name="android:minHeight">16dip</item>
    <item name="android:maxHeight">16dip</item>
</style>

Just create a custom style following the example from the android source code. You would need to replace the android:indeterminateDrawable to what you want.

Prashast
A: 

And the answer was already on SO:

stackoverflow.com/questions/2020882/how-to-change-progress-bars-progress-color-in-android

You can simply change the whole drawable that is shown in the progressbar via the android:indeterminateDrawable attribute.

Janusz