搜索栏拇指大小的改变 [英] Changing size of seekbar thumb

查看:183
本文介绍了搜索栏拇指大小的改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是可绘制的搜索栏大拇指

I'm using a drawable for seekbar thumb with

android:thumb="@drawable/thumb"

我如何设置这个拇指大小的单位?因为我用一种风格的搜索栏像

How can i set the size of this thumb in dip unit? Because i use a style for seekbar like

<style name="CustomSeekBar">
    <item name="android:indeterminateOnly">false</item>
    <item name="android:minHeight">8dip</item>
    <item name="android:maxHeight">8dip</item>
    <item name="android:thumbOffset">8dip</item>
</style> 

和我想与 12dip 的高度和宽度的拇指。

and i want to have the thumb with 12dip height and width.

推荐答案

最灵活的方式来设定拇指大小对我来说是建立分层的抽拉与形状,占位符 thumb_image.xml

The most flexible way to set thumb size for me is to create layered-drawable with shape as placeholder thumb_image.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item>
        <shape>
            <size
                android:height="40dp"
                android:width="40dp" />

            <solid android:color="@android:color/transparent" />
        </shape>
    </item>
    <item android:drawable="@drawable/scrubber_control_normal_holo"/>

</layer-list>

所以基本上改变形状的大小将伸展绘制,形状是透明的,所以它不会是可见的。还如拇指的最小尺寸是位图的大小。

So basically changing the size of shape will stretch drawable, the shape is transparent so it won't be visible. Also the minimum size of such thumb is size of bitmap.

下面是例子布局:

<SeekBar
    android:id="@+id/seekBar1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:thumb="@drawable/thumb_image" />

<SeekBar
    android:id="@+id/seekBar2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

这篇关于搜索栏拇指大小的改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆