ListView에 selector를 사용하려면 ListView에 listSelector 속성으로 줘야한다.
1. ListView 소스
<ListView
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:listSelector="@drawable/list_selector"
android:verticalSpacing="0dp"
android:divider="@drawable/div_list"/>
일반적인 selector와 다르게 android:state_pressed만 설정해주면 클릭시 selector가 적용되지 않는다.
레퍼런스에서는 설명도 못찾겠고 미스테리.
2. selector 소스(list_selector.xml)
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:variablePadding="false">
<item
android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/list_press"
/>
<item
android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/list_press"
/>
<item
android:state_focused="true" android:state_selected="false"
android:drawable="@drawable/list_high"
/>
<item
android:drawable="@color/setup_bg_color"
/>
</selector>