1.如何去掉thumb点击或拖拽时产生的阴影? ——通过自定义SeekBar,然后将android:background="@null"
2.SeekBar的progressDrawable属性 ——为SeekBar进度条的背景,可通过layer-list定义当前进度背景以及整体长度背景(注意不同场合clip标签的使用)。
//bg_volume_slider.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="@color/switch_bar_state_disabled_color" />
<corners android:radius="10dp"/>
<size android:height="14dp"/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<scale android:scaleWidth="100%"
android:drawable="@drawable/bg_progress_bar"/>
<!-- <clip>
<shape>
<corners android:radius="10dp"/>
<solid android:color="@color/qr_focused_corner_line_color"/>
</shape>
</clip>-->
</item>
<item android:id="@android:id/progress">
<scale android:scaleWidth="100%"
android:drawable="@drawable/bg_progress_bar"/>
<!-- <clip>
<shape>
<corners android:radius="10dp"/>
<solid android:color="@color/qr_focused_corner_line_color"/>
</shape>
</clip>-->
</item>
</layer-list>
3.SeekBar的thumb属性
//bg_progress_slider_thumb.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:height="14dp" android:width="14dp"/>
<solid android:color="#fff"/>
<stroke android:color="@color/qr_focused_corner_line_color"
android:width="1dp"/>
</shape>
4.SeekBar的thumbOffset属性 ——当thumb位于进度条最头最尾时相对于进度条头尾的偏移量。
5.SeekBar的splitTrack属性 ——thumb与进度条的切割,值为true/false
6.SeekBar的thumbTint属性 ——thumb的着色器
7.minHeight与maxheight ——定义进度条的高度
SeekBar举例:
<SeekBar android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:outlineSpotShadowColor="#ff0000"
app:layout_constraintBottom_toTopOf="@+id/tv_timeLen"
app:layout_constraintStart_toStartOf="parent"
android:paddingTop="10dp"
android:maxHeight="2dp"
android:minHeight="2dp"
android:progressDrawable="@drawable/seekbar_bg"
android:thumbTint="@color/highlight_color"/>
<SeekBar
android:id="@*android:id/seekbar"
android:layout_gravity="left|center_vertical"
android:layout_width="match_parent"
android:layout_height="15dp"
android:progressDrawable="@drawable/bg_volume_slider"
android:thumb="@drawable/bg_volume_slider_thumb"
android:splitTrack="false" />
<SeekBar
android:id="@*android:id/seekbar"
android:layout_gravity="left|center_vertical"
android:layout_width="match_parent"
android:layout_height="20dp"
android:progressDrawable="@drawable/bg_volume_slider"
android:thumb="@null"
android:thumbOffset="0dp"
android:splitTrack="false" />
<com.xxxxxxx.widget.CustomSeekBar
android:id="@+id/sb_light_bar"
android:layout_width="wrap_content"
android:layout_height="190.0px"
android:layout_centerInParent="true"
android:maxHeight="6dp"
android:background="@null"
android:progressDrawable="@drawable/video_light_seekbar"
android:thumb="@drawable/sele" />