效果样式(没有"完成拼图"这四个字):
使用方式如下:
<androidx.appcompat.widget.AppCompatSeekBar
android:id="@+id/captcha_seek"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:splitTrack="false" //修复5.0以上滑块有白色背景的问题
android:background="@null" //修复点击滑块时候底部有圆点阴影的问题
android:layout_marginTop="@dimen/dp_20"
android:progressDrawable="@drawable/seek_captcha" //设置背景色
android:thumb="@drawable/seekbar_thumb" //设置滑块
android:thumbOffset="@dimen/dp_20" //对滑块进行偏移值修复
android:layout_below="@+id/captcha_img"/>
滑块自定义:
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="@mipmap/seek_thumb" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@mipmap/seek_thumb" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@mipmap/seek_thumb" />
<item android:drawable="@mipmap/seek_thumb" />
</selector>
seekBar进度条样式设置
<?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>
<solid android:color="#E4E4E4" />
<stroke android:color="#BEBEBE" android:width="@dimen/dp_1"/>
<corners android:radius="5dp"/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<solid android:color="#E4E4E4" />
<stroke android:color="#BEBEBE" android:width="@dimen/dp_1"/>
<corners android:radius="5dp"/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="#E4E4E4" />
<stroke android:color="#BEBEBE" android:width="@dimen/dp_1"/>
<corners android:radius="5dp"/>
</shape>
</clip>
</item>
</layer-list>