0

Is it possible to change horizontal indeterminate color? As of now it is take standard theme color.

I would like to change it to orange?

I know we have change the circle color I am not sure to change the horizontal color tried Theme, custom progress bar in drawable etc but couldn't get work.

Here is the XML:

<ProgressBar
   android:id="@+id/status_progress"
   style="?android:attr/progressBarStyleHorizontal"
   android:layout_width="match_parent"
   android:layout_height="15dp"
   android:layout_below="@id/status_text"
   android:indeterminate="true"
   android:indeterminateOnly="true" />
l-l
  • 3,804
  • 6
  • 36
  • 42
TheDevMan
  • 5,914
  • 12
  • 74
  • 144

2 Answers2

2
progressBar.getIndeterminateDrawable()
    .setColorFilter(progressBar.getContext().getResources().getColor(<colorId>),
        PorterDuff.Mode.SRC_IN);
mbmc
  • 5,024
  • 5
  • 25
  • 53
  • we can't do this in XML? as I am using the progress bar in custom notification bar so won't be able access XML – TheDevMan Jun 20 '15 at 00:08
  • This does work but on API 10 you could get colours that do not show correct. My progress bar was green and on a gingerbread device the progress bar appears as a solid green colour. If you change this to use .MULTIPLY one sees the "changing" bar, but this is not accurate colouring by mixing colours. The default bar is light blue chevron in my case. – Wayne Mar 11 '16 at 13:30
-1

use a custom xml drawable orangePogress.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="#ff9d9e9d"
                android:centerColor="#ff5a5d5a"
                android:centerY="0.75"
                android:endColor="#ff747674"
                android:angle="270"
            />
        </shape>
    </clip>
</item>
<item
    android:id="@android:id/progress"
>
    <clip>
        <shape>
            <corners
                android:radius="5dip" />
            <gradient
                android:startColor="#FF6600"
                android:endColor="#FF9933"
                android:angle="270" />
        </shape>
    </clip>
</item>

</layer-list>

and then in your progressbar

<ProgressBar
    android:id="@+id/ProgressBar"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:indeterminate="false"
    android:progressDrawable="@drawable/orangePogress" />
Helmi
  • 556
  • 2
  • 19