自定义搜索栏与API的21式的错误自定义、错误、API

2023-09-05 10:46:13 作者:尤离

这是我的搜索栏

    <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

<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

这是它应该如何看,这是它的外观上奇巧和更低的版本。

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

你知道吗?我有一些问题与棒棒堂的布局,但是这是唯一一个我解决不了我自己。

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