Question

I have some difficulties finding the correct way to specify that a progress bar should have the small indefinite style.

I would be glad if somebody could provide an example for me and others that do a quick search for this information.

Was it helpful?

Solution

The solution is to change the style to

<ProgressBar
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   style="?android:attr/progressBarStyleSmall" />

OTHER TIPS

One more way to do it is

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

Ex_

<ProgressBar
 android:id="@+id/progress_bar"
 style="@android:style/Widget.ProgressBar.Small"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:padding="7dip"
 arandroid:visibility="visible" />

Here is how to do it programmatically:

ProgressBar progress = new ProgressBar(ctx, null, android.R.attr.progressBarStyleSmall);

This may be of use:

style="?android:attr/android:progressBarStyleSmall"
 <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content
        style="?android:attr/progressBarStyleSmallTitle"
        android:layout_height="wrap_content" />

According to the answer of @Rupesh Yadav, you can see a structure of the style @android:style/Widget.ProgressBar.Small:

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

I can confirm that setting min and max sizes solves the problem. Setting width and height explicitly doesn't change the size of the ProgressBar. So you can make your own style.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top