Android: show/hide a view using an animation

Blaskovicz picture Blaskovicz · Feb 12, 2012 · Viewed 109.2k times · Source

I've been looking through many google results / questions on here to determine how to show/hide a view via a vertical animation, but I can't seem to find one that's exactly right or not too vague.

I have a layout (undo bar) that's below another layout and above multiple other widgets; this undo bar should vertically slide open and slide closed, depending on the circumstances.

Currently all I do right now is set the view to be visible or gone.

Answer

pozuelog picture pozuelog · Jan 24, 2014

Set the attribute android:animateLayoutChanges="true" inside the parent layout .

Put the view in a layout if its not and set android:animateLayoutChanges="true" for that layout.

NOTE: This works only from API Level 11+ (Android 3.0)