1.xml布局
<androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/seek_video_fullscreen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:maxHeight="2dp"
android:minHeight="2dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingStart="14.5dp"
android:paddingEnd="5dp"
android:progressDrawable="@drawable/seekbar_style"
android:thumb="@drawable/seekbar_thumb"/>
2.创建seekbar_style.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"
android:gravity="center_vertical|fill_horizontal">
<shape android:shape="rectangle">
<corners android:radius="2dp"/>
<size android:height="1.5dp"/>
<solid android:color="@color/white70"/>
</shape>
</item>
<item
android:id="@android:id/secondaryProgress"
android:gravity="center_vertical|fill_horizontal">
<clip>
<shape android:shape="rectangle">
<corners android:radius="2dp"/>
<size android:height="1.5dp"/>
<solid android:color="@color/white96"/>
</shape>
</clip>
</item>
<item
android:id="@android:id/progress"
android:gravity="center_vertical|fill_horizontal">
<clip>
<shape android:shape="rectangle">
<corners android:radius="2dp"/>
<size android:height="1.5dp"/>
<solid android:color="@color/color_f93952"/>
</shape>
</clip>
</item>
</layer-list>
3.创建seekbar_thumb.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape
android:shape="oval"
android:useLevel="false">
<solid android:color="@color/white"/>
<size
android:width="8dp"
android:height="8dp"/>
</shape>
</item>
<item android:state_focused="true">
<shape
android:shape="oval"
android:useLevel="false">
<solid android:color="@color/white"/>
<size
android:width="8dp"
android:height="8dp"/>
</shape>
</item>
<item>
<shape
android:shape="oval"
android:useLevel="false">
<solid android:color="@color/white"/>
<size
android:width="8dp"
android:height="8dp"/>
</shape>
</item>
</selector>
|