茴香豆的第五种写法---设置ExpandableListView系统自带图标按下效果

时间:2023-03-09 20:28:34
茴香豆的第五种写法---设置ExpandableListView系统自带图标按下效果

1 编写groupindicator_selector.xml如下:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_expanded="true" android:drawable="@drawable/right" />
<item android:drawable="@drawable/down" />
</selector>

再次指定ExpandableListView展开和收缩时的不同图标

2 在布局文件中为<ExpandableListView指定groupIndicator

<ExpandableListView
android:id="@+id/expandableListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:groupIndicator="@drawable/groupindicator_selector"
/>