android - Lollipop API21 上的自定义搜索栏拇指不透明

标签 android layout android-5.0-lollipop android-seekbar

这是我的搜索栏:

<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

<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>    

这就是我在 Lollipop 中看到的样子

Seekbar Lollipop

这就是它应该的样子,这就是它在 Kitkat 和更低版本上的样子。

Seekbar KitKat

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

最佳答案

Material 搜索栏默认启用分割轨道。您需要将其关闭。

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

关于android - Lollipop API21 上的自定义搜索栏拇指不透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26989400/

相关文章:

android - Android Studio:无法正常工作,得到不同的不同错误

android - 我想在 android 中使用带有形状的选择器项选择一个按钮

testing - Rspec 测试布局

Android 与 Picasso 共享元素

android - 相机 FLASH_MODE_ON 不适用于 Moto X

javascript - Phonegap 文件传输插件导致 Android 构建失败

html - 为什么这个 html 表格没有正确对齐?

android - 如何使用 webview 播放 flash 来管理 z-order

android - 父 Activity 在退出过渡时变得不可见

android - 错误 <declare-styleable> MenuView,无法找到属性 android :preserveIconSpacing