56

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.

Jonik
  • 80,077
  • 70
  • 264
  • 372
Janusz
  • 187,060
  • 113
  • 301
  • 369
  • What do you call the small indefinite style? is that when the progress bar is displayed in the title bar? Can't you just use a scaling of the image? – Sephy Aug 17 '10 at 08:29
  • There is a small version of the spinning graphic. I want to use it to display it inside a button to show that the button will be activated once a call to the server is finished – Janusz Aug 17 '10 at 08:31

8 Answers8

155

The solution is to change the style to

<ProgressBar
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   style="?android:attr/progressBarStyleSmall" />
dell116
  • 5,835
  • 9
  • 52
  • 70
Janusz
  • 187,060
  • 113
  • 301
  • 369
  • I searched a lot for a dark progress bar because on white the standard progress bar can nearly not be seen. I painted one myself because I couldn't find one. – Janusz Nov 04 '10 at 17:06
  • 1
    I only found the drawable "spinner_black_76" at http://www.fixedd.com/projects/android_drawables_display -> other – OneWorld Nov 04 '10 at 22:15
16

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" />
Rupesh Yadav
  • 12,096
  • 4
  • 53
  • 70
11

Here is how to do it programmatically:

ProgressBar progress = new ProgressBar(ctx, null, android.R.attr.progressBarStyleSmall);
Tim Visée
  • 2,988
  • 4
  • 45
  • 55
Sileria
  • 15,223
  • 4
  • 49
  • 28
9

This may be of use:

style="?android:attr/android:progressBarStyleSmall"
Kapil Rajput
  • 11,429
  • 9
  • 50
  • 65
Jaspreet Chhabra
  • 1,431
  • 15
  • 23
5

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

Suraj Vaishnav
  • 7,777
  • 4
  • 43
  • 46
3
 <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content
        style="?android:attr/progressBarStyleSmallTitle"
        android:layout_height="wrap_content" />
Sanjeev Pal
  • 187
  • 2
  • 8
  • 1
    Welcome to Stack Overflow! Please don't answer just with source code. Try to provide a nice description about how your solution works. See: [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer). Thanks – sɐunıɔןɐqɐp Sep 26 '18 at 07:42
1
<!--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" />
Mohd Qasim
  • 896
  • 9
  • 20
0

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.

CoolMind
  • 26,736
  • 15
  • 188
  • 224