Reputation:
I am making an app in which i have to use image of group indicator when when applied it shows enlargrd image .Can anyone help me how to set indicator image in expandable list view .Any help will be appreciated.
Upvotes: 1
Views: 6160
Reputation: 161
This version uses the latest ic_keyboard_arrow vector icons (24dp):
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_empty="true">
<layer-list>
<item
android:left="0dp"
android:right="0dp"
android:top="24dp"
android:bottom="24dp"
android:drawable="@drawable/ic_keyboard_arrow_up">
</item>
</layer-list>
</item>
<item android:state_expanded="false">
<layer-list>
<item
android:left="0dp"
android:right="0dp"
android:top="24dp"
android:bottom="24dp"
android:drawable="@drawable/ic_keyboard_arrow_up">
</item>
</layer-list>
</item>
<item android:state_expanded="true">
<layer-list>
<item
android:left="0dp"
android:right="0dp"
android:top="24dp"
android:bottom="24dp"
android:drawable="@drawable/ic_keyboard_arrow_down">
</item>
</layer-list>
</item>
</selector>
Upvotes: 0
Reputation: 2186
The following code may be helpful
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_empty="true">
<layer-list>
<item
android:left="20dp"
android:right="-30dp"
android:top="120dp"
android:bottom="10dp"
android:drawable="@drawable/panier_plus">
</item>
</layer-list>
</item>
<item android:state_expanded="true">
<layer-list>
<item
android:left="20dp"
android:right="-30dp"
android:top="120dp"
android:bottom="10dp"
android:drawable="@drawable/panier_minus"
>
</item>
</layer-list>
</item>
</selector>
Upvotes: 0
Reputation: 1902
a custom drawable is probably what you need. You cant toy with the in built indicator. have a look at this. The group_indicator.xml at the bottom of that page is an example of a custom indicator. You just add this drawable to the android:groupindicator value of you expandablelistview element. This way you can control the indicator behavious and size and with aa few tweaks also hide the indicator if there are no children in the group.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_empty="true" android:drawable="@drawable/arrowright">
<item android:state_expanded="true" android:drawable="@drawable/arrowdown">
<item android:drawable="@drawable/arrowright">
</item></item></item>
</selector>
Hope it helps.
Upvotes: 3