自定义seekbar拇指在Lollipop API21上不透明 [英] Custom seekbar thumb not transparent on Lollipop API21

查看:58
本文介绍了自定义seekbar拇指在Lollipop API21上不透明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的搜索栏:

<SeekBar
    android:id="@+id/seek1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:progressDrawable="@drawable/style_progressbar"
    android:thumb="@drawable/style_progressbar_circle"
    android:progress="20" />

这是 style_progressbar.xml :

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background">
        <shape android:shape="rectangle" >
            <corners android:radius="5dp" />
            <gradient
                android:angle="270"
                android:endColor="@color/gris_hint"
                android:startColor="@color/gris_hint" />
        </shape>
    </item>
    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape android:shape="rectangle" >
                <corners android:radius="5dp" />
                <gradient
                    android:angle="270"
                    android:endColor="@color/gris"
                    android:startColor="@color/gris" />
            </shape>
        </clip>
    </item>
    <item android:id="@android:id/progress">
        <clip>
            <shape android:shape="rectangle" >
                <corners android:radius="5dp" />
                <gradient
                    android:angle="270"
                    android:endColor="@color/gris"
                    android:startColor="@color/gris" />
            </shape>
        </clip>
    </item>
</layer-list>

这是style_progressbar_circle.xml

And this is style_progressbar_circle.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/red_scrubber_control_disabled_holo" android:state_enabled="false"/>
    <item android:drawable="@drawable/red_scrubber_control_pressed_holo" android:state_pressed="true"/>
    <item android:drawable="@drawable/red_scrubber_control_focused_holo" android:state_selected="true"/>
    <item android:drawable="@drawable/red_scrubber_control_normal_holo"/>
</selector>    

这就是我在棒棒糖中看到的方式

This is how I see it in Lollipop

这是它的外观,这是在Kitkat和更低版本上的外观.

This is how it should look, this is how it looks on Kitkat and lower versions.

有什么主意吗?我在Lollipop上的布局存在一些问题,但这是我自己无法解决的唯一问题.

Any idea? I've got some issues with layouts on Lollipop but this is the only one I can't solve for my own.

推荐答案

默认情况下,材料"搜索栏已启用拆分轨道.您需要将其关闭.

The Material seek bar has split track enabled by default. You need to turn it off.

<SeekBar
    ....
    android:splitTrack="false" />

这篇关于自定义seekbar拇指在Lollipop API21上不透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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