list_selector.xml文件
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 没有焦点时的背景颜色 -->
<item android:drawable="@color/transparent" android:state_window_focused="false"/>
<!-- 非触摸模式下获得焦点并单击时的背景颜色 -->
<item android:drawable="@color/transparent_half" android:state_focused="true" android:state_pressed="true"/>
<!-- 触摸模式下单击时的背景颜色 -->
<item android:drawable="@color/transparent_half" android:state_focused="false" android:state_pressed="true"/>
<!-- 选中时的背景颜色 -->
<item android:drawable="@color/transparent_half" android:state_selected="true"/>
<!-- 获得焦点时的背景 颜色 -->
<item android:drawable="@color/transparent" android:state_focused="true"/>
</selector>item.xml引用list_selector
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="50dip"
android:orientation="vertical"
android:background="@drawable/list_selector"
android:gravity="center">
<TextView
android:id="@+id/tv_productline1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="15dip"
android:text="TextView"
android:textColor="#000000" />
</LinearLayout>
list_selector_transparent.xml覆盖ListView默认的样式
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 没有焦点时的背景颜色 -->
<item android:drawable="@color/transparent" android:state_window_focused="false"/>
<!-- 非触摸模式下获得焦点并单击时的背景颜色 -->
<item android:drawable="@color/transparent" android:state_focused="true" android:state_pressed="true"/>
<!-- 触摸模式下单击时的背景颜色 -->
<item android:drawable="@color/transparent" android:state_focused="false" android:state_pressed="true"/>
<!-- 选中时的背景颜色 -->
<item android:drawable="@color/transparent" android:state_selected="true"/>
<!-- 获得焦点时的背景 颜色 -->
<item android:drawable="@color/transparent" android:state_focused="true"/>
</selector>
<ListView
android:id="@+id/lv_productline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:descendantFocusability="afterDescendants"
android:divider="@drawable/divider_line"
android:fadingEdge="none"
android:focusable="true"
android:listSelector="@drawable/list_selector_transparent"
android:focusableInTouchMode="true"
android:scrollbarFadeDuration="0"
android:fadeScrollbars="false" >
ListView背景样式定制
179

被折叠的 条评论
为什么被折叠?



