How can I recreate the layout animation affects you see in the Gmail app on Android 3.0+
I know you can use PropertyAnimators, ObjectAnimators, etc., but in my scenario, I have a several fragments on the screen which can be interchanged, so they're all contained within their own FrameLayouts, and all the FrameLayouts are in a RelativeLayout.
I can't figure out how to change the width of the FrameLayouts, since you have to edit that through the LayoutParams object.
Any ideas?
My take on this can be viewed on GitHub here
It demonstrates one way of hiding a fragment with an animation, like Gmail does.
The animation isn't perfect as the left fragment is moving slightly faster than the right fragment is.
The method that does the hiding defines the animation in code and looks as follows:
To make this work, you need to define that you want layout transition to be animated. One line in the top of your layout's xml structure will do that:
If you don't want custom animations, you can remove everything before FragmentManager fragmentManager = getFragmentManager().
Now in my example I use fragments but the same principle should apply to any view.
Edit: Instead of changing the widths of your views manually, you should use layout weights instead to allow automatic resizing.