效果图:
XML创建:
< ProgressBar
android: id = "@+id/bar_radio"
android: background = "@drawable/bgd_bar"
android: progressDrawable = "@drawable/progressbar"
android: layout_width = "120dp"
android: layout_height = "10dp"
style = "?android:attr/progressBarStyleHorizontal"
android: max = "100"
android: progress = "0" / >
背景设置:
@drawable/bgd_bar:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="15dp" />
<solid android:color="#00000000"/>
<stroke android:width="1dp" android:color="@color/text_red"/>
<padding android:left="1dp" android:top="1dp"
android:right="1dp" android:bottom="1dp" />
</shape>
内部填充设置:
@drawable/progressbar:
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/progress">
<clip>
<shape>
<gradient
android:endColor="#f4457a"
android:startColor="#f4457a"/>
</shape>
</clip>
</item>
</layer-list>
代码内动态填充数值事例: barRadio.setProgress(50);