1

I have a static progress bar which just displays a stagnant data in the bar. i want to change the default color i.e. yellow. This solution didnt help as my progress bar became a horizontal gray animation. Please help.

Community
  • 1
  • 1
Umang
  • 583
  • 2
  • 12
  • 28
  • 1
    Try this too : http://stackoverflow.com/questions/2020882/how-to-change-progress-bars-progress-color-in-android – Vinayak Bevinakatti Sep 19 '11 at 07:15
  • your question is related to [this][1]. [1]: http://stackoverflow.com/questions/2020882/how-to-change-progress-bars-progress-color-in-android – CMA Sep 19 '11 at 07:45
  • 1
    @vinayak thanks. It worked. Can you tell how can I change the gray color in the progress bar as well? I mean the gray color that displays the remaining region. – Umang Sep 19 '11 at 08:22

1 Answers1

0

You can custom progress bar style.

Look like bellow:

    <ProgressBar
    android:id="@+id/progressbar"
    style="@android:style/Widget.Holo.Light.ProgressBar.Horizontal"
    android:progressDrawable="@drawable/whiteprogress"
    android:indeterminate="false"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:maxHeight="18dip"
    android:minHeight="18dip" />

And create whiteprogress.xml file:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="2dip" />

            <gradient
                android:angle="270"
                android:centerColor="#26A69A"
                android:centerY="0.75"
                android:endColor="#26A69A"
                android:startColor="#26A69A" />
        </shape>
    </item>
    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape>
                <corners android:radius="2dip" />

                <gradient
                    android:angle="270"
                    android:centerColor="#80ffb600"
                    android:centerY="0.75"
                    android:endColor="#a0ffcb00"
                    android:startColor="#80ffd300" />
            </shape>
        </clip>
    </item>
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <corners android:radius="2dip" />

                <gradient
                    android:angle="270"
                    android:endColor="#ffffff"
                    android:startColor="#ffffff" />
            </shape>
        </clip>
    </item>

</layer-list>
Ve Pham
  • 303
  • 1
  • 9