1.效果图
先上规矩,符合大家需求的,就往下看,不符合就右上角。
2.步骤
2.1 画进度条
用xml画进度条,包括背景颜色,二级背景颜色,已经加载的颜色。
bg_seekbar_progress_drawable.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>
<corners android:radius="5dp"/>
<size android:height="3dp" />
<solid android:color="#505050"/>
</shape>
</item>
<!--缓冲进度-->
<item android:id="@android:id/secondaryProgress" >
<clip>
<shape>
<corners android:radius="5dp"/>
<size android:height="3dp" />
<solid android:color="#858585"/>
</shape>
</clip>
</item>
<!-- 进度背景 00ade6-->
<item android:id="@android:id/progress" >
<clip>
<shape>
<corners android:radius="5dp"/>
<size android:height="3dp" />
<solid android:color="#0485e0"/>
</shape>
</clip>
</item>
</layer-list>
2.2 画一个蓝色的实心圆点
还是用xml写。yuan.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
>
<size
android:width="20dp"
android:height="20dp"
/>
<solid android:color="#0485e0" />
</shape>
2.3 在布局文件使用
<SeekBar
android:progressDrawable="@drawable/bg_seekbar_progress_drawable"
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:layout_marginLeft="40dp"
android:splitTrack="false"
android:secondaryProgress="60"
android:maxHeight="5dip"
android:thumb="@drawable/yuan"
/>
3.遇到问题
3.1 thumb不居中显示
添加代码: android:maxHeight="5dip" 即可
3.2 thumb 和seekbar有间隙,或者会有黑色边框之类
添加代码: android:splitTrack="false"