SeekBar的高度及thumb圆点显示不完全

2019-06-24 06:18:52


参考链接  SeekBar的高度及thumb圆点显示不完全


直接进入正题,请看以下代码:


<SeekBar

    android:id="@+id/seekbar_def"

    android:layout_width="match_parent"

    android:layout_height="wrap_content"

    android:layout_below="@+id/distance"

    android:max="25"

    android:maxHeight="@dimen/x5"

    android:minHeight="@dimen/x5"

    android:progress="0"

    android:progressDrawable="@drawable/selector_seekbar_bg"

    android:thumb="@drawable/shape_point_circular"

    android:thumbOffset="0dip" />

1

2

3

4

5

6

7

8

9

10

11

12

控制SeekBar条的高度在于这三个属性


android:layout_height="wrap_content"

android:maxHeight="@dimen/x5"

android:minHeight="@dimen/x5"

1

2

3

maxHeight和minHeight越大,则条的高度越大。


至于圆点,也就是thumb的大小,如果你使用的是图片,那么你的图片有多大,在这种属性设置下都会显示完全,但是无法控制圆点大小。但是我发现如果使用shape来绘制圆点的话,是有一个属性来控制圆点大小。


android:thumb="@drawable/shape_point_circular"

1

这个属性用来自定义圆点,shape_point_circular的内容如下:


<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android" >


    <!-- 绿色圆点-->


    <solid android:color="#6fb737" />


    <corners android:radius="8dp"/>


    <size

        android:height="15dp"

        android:width="15dp"/>


</shape>

1

2

3

4

5

6

7

8

9

10

11

12

13

14

其中size内的height和width可以用来控制画出的圆点的大小。


顺便记录一下这个控件的其他参数


android:progressDrawable="@drawable/selector_seekbar_bg"

1

这个属性用来自定义条的样式,我都是用绘画的方式实现的,以下是selector_seekbar_bg的内容:


<?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 android:shape="rectangle" >

            <solid android:color="@color/gray" />


            <corners android:radius="@dimen/x5" />

        </shape>

    </item>

    <item

        android:id="@android:id/progress">

        <clip>

            <shape android:shape="rectangle" >

                <corners android:radius="@dimen/x5" />


                <solid android:color="@color/title_color" />

            </shape>

        </clip>

    </item>


</layer-list>

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

android:max="25"

1

整个控件的最大值,可以理解为SeekBar的圆点滚动25下即滚动到最右边。


android:progress="0"

1

表示默认值,即圆点初始位置。


android:thumbOffset="0dip"

1

这个属性需要注意咯,当你不设置这个属性的话,你的圆点在最左边的时候是会显示不全的。


  • 2020-05-24 08:10:18

    echarts标题(title)配置

    show:true,//显示策略,默认值true,可选为:true(显示) | false(隐藏) text: '主标题',//主标题文本,'\n'指定换行 link:'',//主标题文本超链接,默认值true target: null,//指定窗口打开主标题超链接,支持'self' | 'blank',不指定等同为'blank'(新窗口) subtext: '副标题',//副标题文本,'\n'指定换行 sublink: '',//副标题文本超链接

  • 2020-06-02 08:57:12

    clipboard复制成功但是粘贴板是空的

    将文本复制到剪贴板应该不难。配置它不需要几十个步骤,也不需要加载数百KB的js文件 。但最重要的是,它不应该依赖Flash或任何臃肿的框架。这就是clipboard.js存在的原因。