0

I have a customized ProgressBar which gets its drawable from the drawable folder.

The XML:

<?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="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="#33FF33"
                android:endColor="#008000"
                android:angle="270" />
         </shape>
    </clip>
</item>

</layer-list>

I want to be able to change the startColor of progress (which is "#33FF33" in the XML). I need an alternative way to set the color.

lg, couka

Rudi Kershaw
  • 12,332
  • 7
  • 52
  • 77
couka
  • 1,361
  • 9
  • 16

1 Answers1

0

After this line ,your ProgressBar will be in RED color: you can change it as you want

progressBar.getProgressDrawable().setColorFilter(Color.RED, Mode.SRC_IN); 

Or try this solution : https://stackoverflow.com/a/11288434/2337837

Community
  • 1
  • 1
Zied R.
  • 4,964
  • 2
  • 36
  • 67
  • Just realised this doesn't fix their problem either because they need to set the start colour of a gradient, not the whole colour. – Rudi Kershaw Mar 01 '14 at 14:07