85

When uninstalling an android application, or do some configuration, there will show such a horizontal progress bar, like following picture:

progress bar

It's not the same style like @android:style/Widget.ProgressBar.Horizontal.

How to use it in my own application?

Freewind
  • 177,284
  • 143
  • 381
  • 649

5 Answers5

190

Just add a STYLE line and your progress becomes horizontal:

<ProgressBar
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/progress"
        android:layout_centerHorizontal="true"      
        android:layout_centerVertical="true"      
        android:max="100" 
        android:progress="45"/>
AskNilesh
  • 58,437
  • 15
  • 99
  • 129
Vitas
  • 2,087
  • 2
  • 10
  • 5
73

It is Widget.ProgressBar.Horizontal on my phone, if I set android:indeterminate="true"

Sergey Glotov
  • 19,479
  • 11
  • 78
  • 93
  • 7
    Also, be sure to set height to `wrap_content` (or something bigger), I've lost almost an hour to figure out why the progress bar wasn't showing... -.- – milosmns Dec 18 '14 at 12:26
66

For using the new progress bar

style="?android:attr/progressBarStyleHorizontal"

for the old grey color progress bar use

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

in this one you have the option of changing the height by setting minHeight

The complete XML code is:

    <ProgressBar
    android:id="@+id/pbProcessing"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/tvProcessing"
    android:indeterminateOnly="true"/>

indeterminateOnly is set to true for getting indeterminate horizontal progress bar

Stephen Talley
  • 823
  • 13
  • 13
Jaspinder Kaur
  • 959
  • 10
  • 11
13

Progress Bar in Layout

<ProgressBar 
               android:id="@+id/download_progressbar"
               android:layout_width="200dp"
               android:layout_height="24dp"
               android:background="@drawable/download_progress_bg_track"
               android:progressDrawable="@drawable/download_progress_style"
               style="?android:attr/progressBarStyleHorizontal"
               android:indeterminate="false"
               android:indeterminateOnly="false" />

download_progress_style.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/progress">
    <scale 
      android:useIntrinsicSizeAsMinimum="true" 
      android:scaleWidth="100%" 
      android:drawable="@drawable/store_download_progress" />
</item>

Harpreet
  • 2,578
  • 3
  • 31
  • 48
venciallee
  • 715
  • 4
  • 19
6

Worked for me , can try with the same

<ProgressBar
    android:id="@+id/determinateBar"
    android:indeterminateOnly="true"
    android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
    android:indeterminateDuration="10"
    android:indeterminateBehavior="repeat"
    android:progressBackgroundTint="#208afa"
    android:progressBackgroundTintMode="multiply"
    android:minHeight="24dip"
    android:maxHeight="24dip"
    android:layout_width="match_parent"
    android:layout_height="10dp"
    android:visibility="visible"/>
Tarit Ray
  • 798
  • 9
  • 23