change color of horizontal progress bar
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 anima开发者_如何学Pythontion. Please help.
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>
精彩评论