笔记——Android自定义seekbar中,滑块显示不全解决办法

来源:互联网 发布:effective java百度云 编辑:程序博客网 时间:2024/06/01 07:46

自定义seekBar的时候发现,圆形滑块总有一部分被覆盖,设置什么padding之类的病不起作用,查找资料发现

android:thumbOffset="0dp"

在布局文件中加上thumbOffset属性可以解决,thumbOffset属性表示滑块距离左侧的间距。


下面附上自定义SeekBar

<SeekBar            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_weight="1"            android:maxHeight="4dp"            android:minHeight="4dp"            android:paddingLeft="16dp"            android:paddingRight="16dp"            android:thumbOffset="0dp"            android:progressDrawable="@drawable/bg_seek_bar_drawable"            android:thumb="@drawable/ic_seek_bar" />

其中bg_seek_bar_drawable文件设置seekbar进度条的样式,文件如下:

<?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="#8e8e8e" />        </shape>    </item>    <item android:id="@android:id/secondaryProgress">        <clip>            <shape>                <solid android:color="#008e8e8e" />            </shape>        </clip>    </item>    <item android:id="@+android:id/progress">        <clip>            <shape>                <solid android:color="#ffa74b" />            </shape>        </clip>    </item></layer-list>
ic_seek_bar为一张滑块的图片,效果如下图


阅读全文
0 0
原创粉丝点击