Android Seek自定义样式

效果样式(没有"完成拼图"这四个字):
在这里插入图片描述
使用方式如下:

<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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值