defines the property android:background
, which in this case does not work as background
of ProgressBar
if not as the color of the element:
android:background ="@drawable/mipbstyle"
inside your folder / drawable (inside / res) create the file that defines the background and contains your custom color mipbstyle.xml
:
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
android:toDegrees="360">
<shape android:shape="ring" android:innerRadiusRatio="3"
android:thicknessRatio="9" android:useLevel="false">
<size android:width="76dip" android:height="76dip" />
<gradient android:type="sweep" android:useLevel="false"
android:startColor="#001100"
android:endColor="#00FF00"
android:angle="0"/>
</shape>
</rotate>
Modifying your progressBar a bit would be like:
<ProgressBar
android:id="@+id/pg_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_gravity="center"
android:layout_marginTop="25dp"
android:max="500"
android:progress="0"
android:progressDrawable="@drawable/mipbstyle" />
or programmatically through:
myProgressBar.getIndeterminateDrawable()
.setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN);
in both cases you would get something similar to: