listview的item布局范例
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:duplicateParentState="true"
android:background="@mipmap/service_list_item_bg">
//ImageView选中框要放在一个指定大小的布局中
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:duplicateParentState="true"
android:scaleType="fitXY"
android:background="@drawable/service_list_select"/>
</RelativeLayout>
</RelativeLayout>
service_list_select内容为:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@drawable/service_list_select_shape"/>
<item android:state_pressed="true" android:drawable="@drawable/service_list_select_shape" />
<item android:state_selected="true" android:drawable="@drawable/service_list_select_shape"/>
<item android:state_focused="false" android:drawable="@android:color/transparent"/>
</selector>