我希望所选项目在展开时高亮显示,在折叠时返回其原始状态(未高亮显示)。
AnimatedExpandableListView的xml:
<com.packagename.library.AnimatedExpandableListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:divider="@null"
android:dividerHeight="0dp"
android:choiceMode="singleChoice"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/list_selector"/>
以及可为所选状态侦听器绘制的背景:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/blue_linear_layout" android:color="@color/white" android:state_selected="true"/>
<item android:drawable="@drawable/blue_linear_layout" android:color="@color/white" android:state_activated="true"/>
<item android:drawable="@drawable/gray_linear_layout" />
</selector>
背景
choiceMode=singleChoice
list_selector
可绘制到常规ListView的项目背景效果很好,但它似乎在AnimatedExpandableListView上不起作用。
Here