How can I change the style of a ProgressBar to small?

AndroidAndroid ProgressbarAndroid Styles

Android Problem Overview


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.

Android Solutions


Solution 1 - Android

The solution is to change the style to

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

Solution 2 - Android

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

Solution 3 - Android

Here is how to do it programmatically:

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

Solution 4 - Android

This may be of use:

style="?android:attr/android:progressBarStyleSmall"

Solution 5 - Android

You can change the size of progress bar easily by scaleX and scaleY property, like this:

<ProgressBar
        android:id="@+id/progressBar"
        android:scaleX="0.5"
        android:scaleY="0.5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

Here,

scaleX: To change the width, so 0.5 will reduce the width to the half of the actual width

scaleY: To change the height, so 0.5 will reduce the height to the half of actual height

Solution 6 - Android

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

Solution 7 - Android

<!--changing of color,small size spinner-->
    <style name="progressColor" parent="@android:style/Widget.ProgressBar.Small">
        <item name="colorControlActivated">@color/colorPrimary</item>
    </style>

you can achieve color and small size spinner by using above style in spinner

<ProgressBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/progressColor"
            android:layout_gravity="center" />

Solution 8 - Android

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJanuszView Question on Stackoverflow
Solution 1 - AndroidJanuszView Answer on Stackoverflow
Solution 2 - AndroidRupesh YadavView Answer on Stackoverflow
Solution 3 - AndroidSileriaView Answer on Stackoverflow
Solution 4 - AndroidJaspreet ChhabraView Answer on Stackoverflow
Solution 5 - AndroidSuraj VaishnavView Answer on Stackoverflow
Solution 6 - AndroidSanjeev PalView Answer on Stackoverflow
Solution 7 - AndroidMohd QasimView Answer on Stackoverflow
Solution 8 - AndroidCoolMindView Answer on Stackoverflow