+ Reply to Thread
Results 1 to 2 of 2

Thread: How to change progress bar's progress color in Android

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    15

    How to change progress bar's progress color in Android

    I'm using an horizontal progress bar in my Android application, and I want to change its progress color (which is Yellow by default). How can I do it using code (not XML)?

  2. #2
    Junior Member
    Join Date
    Jul 2012
    Posts
    8
    I'm sorry if it's not the answer, but what's driving the requirement setting it from code ? And .setProgressDrawable should work if it's defined correctly
    Code:
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    
    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="5dip" />
            <gradient
                    android:startColor="#ff9d9e9d"
                    android:centerColor="#ff5a5d5a"
                    android:centerY="0.75"
                    android:endColor="#ff747674"
                    android:angle="270"
            />
        </shape>
    </item>
    
    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape>
                <corners android:radius="5dip" />
                <gradient
                        android:startColor="#80ffd300"
                        android:centerColor="#80ffb600"
                        android:centerY="0.75"
                        android:endColor="#a0ffcb00"
                        android:angle="270"
                />
            </shape>
        </clip>
    </item>
    <item
        android:id="@android:id/progress"
    >
        <clip>
            <shape>
                <corners
                    android:radius="5dip" />
                <gradient
                    android:startColor="@color/progress_start"
                    android:endColor="@color/progress_end"
                    android:angle="270" />
            </shape>
        </clip>
    </item>
    
    </layer-list>

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts