SeekBar的样式

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" />

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值