Reputation: 885
I am trying to animate the expansion and collapse of an ExpandableListView. I am targeting API level 15 so there is available a method expandGroup (int groupPos, boolean animate)
. However it does not animate the expansion of the group. My code is below:
m_expandList.setOnGroupClickListener(new OnGroupClickListener(){
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id)
{
if(m_expandList.isGroupExpanded(groupPosition))
{
m_expandList.collapseGroup(groupPosition);
}
else
{
m_expandList.expandGroup(groupPosition,true);
}
return true;
}
});
Below is the extract from the layout:
<ExpandableListView
android:id="@+id/ExpList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/MainLabel"
android:layout_above="@id/button1"
android:choiceMode="multipleChoice"/>
I think that it might be a case of not using the API correctly or maybe missing something?
Also, why isn't there the same method for the collapseGroup (I mean also including the animate bool)?
Thanks in advance
Upvotes: 3
Views: 2718
Reputation: 46
It might be a bit late but the expansion animation triggers when you expand the group where the children of that group has more height than the space available.
The animation is actually the listview scrolling down to accommodate the children height. That is also the reason why there is no animation on collapse.
Hope this helps.
Upvotes: 3
Reputation: 10190
Remove the listener(if you are using it just for expanding-collapsing of groups). That is already the default behavior of an ExpandableListView
which in-fact is animated.
Upvotes: 0