2015-06-20 31 views
0

是否可以更改水平不确定颜色?截至目前,它是采取标准的主题颜色。更改水平进度条不确定颜色

我想将其更改为橙色?

我知道我们已经改变了圆的颜色我不确定要改变水平颜色的主题,可绘制等定制进度条,但无法工作。

这里是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" /> 

回答

2
progressBar.getIndeterminateDrawable() 
    .setColorFilter(progressBar.getContext().getResources().getColor(<colorId>), 
     PorterDuff.Mode.SRC_IN); 
+0

我们不能做这在XML?因为我在自定义通知栏中使用进度条,所以无法访问XML – TheDevMan

+0

这不起作用,但在API 10上,您可能会看到颜色显示不正确。我的进度条是绿色的,在姜饼装置上,进度条显示为纯绿色。如果您更改此设置以使用.MULTIPLY,则会看到“更改”栏,但这不是通过混合颜色进行的准确着​​色。在我的情况下,默认的酒吧是淡蓝色的雪佛龙。 – Wayne

-1

使用自定义XML绘制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> 

,然后在你的进度

<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" /> 
+0

我需要不确定是真实的。 – TheDevMan

+0

你可以将它设置为true – Helmi

+0

如果我这样做,颜色变成黑色和白色。 – TheDevMan