Android——对原生组件的个性化修饰

1.ProgressBar的进度条颜色变更

使用indeterminateTint属性即可

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminateTint="@color/blue" />

原来是一个粉色的,现在变成了蓝色 

 

2.SeekBar的滑块样式和进度条颜色控制

        <SeekBar
            android:id="@+id/mSeekBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:progressDrawable="@drawable/progress_style"
            android:thumb="@drawable/thumb_style" />

滑块样式设置(thumb_style.xml)

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:useLevel="false">
    <solid android:color="@color/colorWhite"></solid>  <!-- 颜色-->
    <size
        android:width="12dp"
        android:height="12dp"></size>
</shape>

进度条颜色设置(progress_style.xml)

这里说明一下item的id名称代表含义:

background:代表进度条的背景颜色

secondaryProgress:代表缓冲进度条的颜色(这里我没有用到)

progress:代表进度条的颜色

<?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="#54000000"/><!--前两位代表颜色透明度-->
        </shape>
    </item>

<!--    <item android:id="@android:id/secondaryProgress">-->
<!--        <clip>-->
<!--            <shape>-->
<!--                <solid android:color="#f9062a"/>-->
<!--            </shape>-->
<!--        </clip>-->
<!--    </item>-->

    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <solid android:color="@color/blue"/>
            </shape>
        </clip>
    </item>

</layer-list>

效果图 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值