使用ProgressBar时,用layer+shape设置好圆角后,发现只有外层背景有圆角,进度条并没有设置成圆角,倒腾半天后终于搞定了,下面放出完整的布局配置
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="10dp"
android:max="100"
android:progress="50"
android:progressDrawable="@drawable/layer_pd" />
layer_pd.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 android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="#eeeeee" />
</shape>
</item>
<item android:id="@android:id/progress">
<scale
android:drawable="@drawable/custom_progress_primary"
android:scaleWidth="98%" />
</item>
</layer-list>
custom_progress_primary.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="10dp" />
<solid android:color="#FF5000" />
</shape>