Animation for expandableListView

android, animation, expandablelistview

Solution

It can be done using a simple ListView that contains an initially hidden view and a custom class that extends Animation. The basic idea is to start with `View.GONE` then gradually re-size the margin from a negative value to the required size while setting visibility to `View.VISIBLE`.

See:

- https://github.com/tjerkw/Android-SlideExpandableListView

- Android Animation: Hide/Show Menu

- How do I animate View.setVisibility(GONE)

..and finally

- Cool toolbar for ListView items + source

The last example contains all the code you need. It looks a bit hackish to me, especially the fact that you must initially set `view.bottomMargin = -50` or more, otherwise the animation does not work properly the first time, but so far I did not find any viable alternative (apart from using a ScrollView with your own container items instead of a ListView).

And finally, this app includes the above example, among lots of other useful examples with links to sources:

- https://market.android.com/details?id=com.groidify.uipatterns

Update: Google removed the app from play store allegedly for intellectual property violation (although it only contained demos and links to open source projects), the author now made the apk available for direct download from http://goo.gl/ihcgs For more details see https://plus.google.com/108176685096570584154/posts. NB: I'm not affiliated with the author.

Problem

Is it possible to apply an expand or collapse animation for expandableListView?

Original source

Related problems