美文网首页
Android Seekbar透明滑动球thumb 不透明的解决

Android Seekbar透明滑动球thumb 不透明的解决

作者: hao_developer | 来源:发表于2021-09-08 10:12 被阅读0次

修改前:


image.png

修改后:


image.png
布局:
<SeekBar
  android:id="@+id/seekBar"
  android:background="@android:color/transparent"
  android:thumbOffset="0dp"
  android:thumb="@drawable/thumb_bar"
  android:layout_marginTop="50dp"
 android:progressDrawable="@drawable/seek_bar_bg"
 android:progress="50"
 android:max="100"
 android:splitTrack="false"
  android:layout_width="match_parent"
  android:layout_height="wrap_content" />

seek_bar_bg.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>
            <solid android:color="#ffffffff" />
            <corners android:radius="10dp"/>
        </shape>
    </item>
    <item android:id="@android:id/progress" >
        <clip>
            <shape>
                <solid android:color="#ffff8c00" />
                <corners android:radius="10dp"/>
            </shape>
        </clip>
    </item>

</layer-list>

thumb_bar.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- 按下状态 -->
    <item android:state_pressed="true"
        android:drawable="@drawable/thumb_dn" />

    <!-- 焦点状态 -->
    <item android:state_focused="true"
        android:drawable="@drawable/thumb_up" />

    <!-- 默认状态 -->
    <item android:drawable="@drawable/thumb_up" />

</selector>

主要属性:\color{red}{android:splitTrack="false" android:background="@null"}\

相关文章

网友评论

      本文标题:Android Seekbar透明滑动球thumb 不透明的解决

      本文链接:https://www.haomeiwen.com/subject/aoxvwltx.html