SeekBar样式(滑动块)

Posted by アライさん on 2019年10月22日

maxHeight控制底色高度

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<SeekBar
android:id="@+id/seekBar"
android:layout_marginLeft="30px"
android:layout_marginRight="30px"
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:splitTrack="false"
android:maxHeight="15dp"
android:progressDrawable="@drawable/seekbar_bg"
android:thumb="@drawable/seekbar_thumb"
android:thumbOffset="0dp"
android:max="143"
android:progress="0"/>

seekbar_bg.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?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="#ff51495e" />
<corners android:radius="8dp" />
</shape>
</item>
<!--<item android:id="@android:id/secondaryProgress">-->
<!--<shape>-->
<!--<solid android:color="#f9062a"/>-->
<!--</shape>-->
<!--</item>-->
<item android:id="@android:id/progress">
<shape>
<solid android:color="#ff51495e" />
<corners android:radius="8dp" />
</shape>
</item>
</layer-list>

seekbar_thumb.xml

1
2
3
4
5
6
7
8
9
10
11
12
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size
android:width="100dp"
android:height="30dp" />

<solid android:color="#2db334" />
<corners
android:radius="20dp"
/>
</shape>