1、修改style为水平样式
style="?android:attr/progressBarStyleHorizontal"
2、定义自定义的颜色及样式
<?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 android:shape="rectangle">
<solid android:color="#FFF0F0F0" />
<corners android:radius="5dp" />
</shape>
</item>
<!--进度-->
<item android:id="@android:id/progress">
<scale
android:drawable="@drawable/progress_round"
android:scaleWidth="100%"/>
</item>
</layer-list>
使用<scale/>使双端圆角,否则右侧圆角会被切掉。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FF4CA0FF"/>
<corners android:radius="5dp"/>
</shape>
3、替换默认样式
android:progressDrawable="@drawable/layer_list_progress_bg"
4、颜色动态设置
LayerDrawable layerDrawable = (LayerDrawable) progressBar.getProgressDrawable();
ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);
GradientDrawable gradientDrawable = (GradientDrawable) scaleDrawable.getDrawable();
gradientDrawable.setColor(Color.parseColor(alarmDateBean.Color));