I set the progressbar style using the code below.
I declared a progressbar widget:
<ProgressBar
android:id="@+id/loadProgress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="20dip"
android:max="100"
android:progressDrawable="@drawable/load_progress"
android:progress="0" />
defined "@ drawable / load_progress"
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@android:id/background"
android:drawable="@drawable/background_bk">
</item>
<item
android:id="@android:id/progress"
android:drawable="@drawable/progress_bk">
</item>
</layer-list>
defined "@ drawable / background_bk" (red)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="0"
android:endColor="#ff0000"
android:startColor="#ff0990" />
<stroke
android:width="1dp"
android:color="#ff0000" />
</shape>
@ drawable / progress_bk set (it is green)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="0"
android:endColor="#00ff00"
android:startColor="#00ff00" />
<stroke
android:width="1dp"
android:color="#00ff00" />
</shape>
The progress indicator is always displayed completely green (how it should look when the progress value is 100), even if I set the progress value to less than 100. Any input would be appreciated.
source
share