自定义搜寻栏(缩略图大小,颜色和背景) [英] Custom seekbar (thumb size, color and background)

查看:101
本文介绍了自定义搜寻栏(缩略图大小,颜色和背景)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Android项目中使用这个seekbar:

I would like to have this seekbar in my Android project :

这是我的搜索栏:

<SeekBar
        android:id="@+id/seekBar_luminosite"
        android:layout_width="@dimen/seekbar_width"
        android:layout_height="@dimen/seekbar_height"
        android:minHeight="15dp"
        android:minWidth="15dp"
        android:maxHeight="15dp"
        android:maxWidth="15dp"
        android:progress="@integer/luminosite_defaut"
        android:progressDrawable="@drawable/custom_seekbar"
        android:thumb="@drawable/custom_thumb" />

这是我的custom_thumb.xml:

This is my custom_thumb.xml :

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

    <gradient
        android:angle="270"
        android:endColor="@color/colorDekraOrange"
        android:startColor="@color/colorDekraOrange" />

    <size
        android:height="35dp"
        android:width="35dp" />

</shape>

这是我的custom_seekbar.xml:

This is my custom_seekbar.xml :

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

    <item
        android:id="@android:id/background"
        android:drawable="@drawable/seekbar"/>
    <item android:id="@android:id/progress">
        <clip android:drawable="@color/colorDekraYellow" />
    </item>

</layer-list>

这是我的seekbar.png(背景):

This is my seekbar.png (background) :

这是结果:

栏中没有阴影,也没有圆形边框...

No shadow and no rounded borders in the bar...

我真的不知道该怎么做.

I really not understand how I can do.

推荐答案

  • 首先,使用android:splitTrack="false"解决拇指的透明性问题.

    • First at all, use android:splitTrack="false" for the transparency problem of your thumb.

      对于seekbar.png,您必须使用 9补丁.这对圆角边框和图像阴影会很有帮助.

      For the seekbar.png, you have to use a 9 patch. It would be good for the rounded border and the shadow of your image.

      这篇关于自定义搜寻栏(缩略图大小,颜色和背景)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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