Android搜索栏:点击时拇指变为黄色

时间:2015-03-24 00:47:23

标签: android seekbar

这是我的搜索栏

    <SeekBar
    android:thumb="@drawable/thumb"
    android:progressDrawable="@android:color/transparent"
    android:background="@android:color/transparent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

这是拇指:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:drawable/status_bar_item_app_background">
        <shape android:shape="rectangle">
            <solid android:color="@color/white"/>
            <size android:width="5dp"/>
        </shape>
    </item>
</selector>

单击搜索栏时,它变为黄色。我希望它不会改变。我该怎么做?

1 个答案:

答案 0 :(得分:0)

您正以错误的方式使用选择器。你忘记了把状态。遵循这种模式:

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

Source

祝你好运!