我正在尝试为列表视图中的每个项目设置一些自定义选择器状态.我试过以下"
list_selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:drawable="@drawable/row_selected_background" />
<item android:state_activated="true"
android:drawable="@drawable/row_selected_background" />
<item android:state_focused="true"
android:drawable="@drawable/row_selected_background" />
<item android:drawable="@drawable/row_background" />
</selector>
Run Code Online (Sandbox Code Playgroud)
list.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/row_background"
android:listSelector="@drawable/list_selector">
</ListView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
由于某种原因,列表未选择的背景颜色是定义的.但on on/click始终是列表的默认android holo blue.我究竟做错了什么?