Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drop Down Panning Android Fragment Transition

I'm using Android Fragments. I want to achieve the effect below.

I have 2 fragments details and a main-body. On a button click I want the details panel slide down and pan out part of the main-body.

The details panel isn't declared in the activity's xml layout. It is being added dynamically. Also the details panel can be dismissed when the user is done with it.

I found an example of exactly what I want to do. The Gmail app in honeycomb does this when you have it in portrait mode on the Xoom. Navigate all the way to an email such that it is take up the whole screen. Press the back button and notice the email body pans to the right to make room for the email messages list.

Before and after of the activity.

like image 789
Jeremy Edwards Avatar asked Jul 30 '11 23:07

Jeremy Edwards


1 Answers

The best approach I've currently seen and use (with views but should work for fragments as well) is following: http://udinic.wordpress.com/2011/09/03/expanding-listview-items/

Basically he creates a view with negative margin and then he animates the margin to the desired value. This basically transforms the view properly instead of just doing a simple animation. I'm working on my own implementation that uses height instead of margin.

I'm VERY interested in a better approach. This gets the job done, but I don't like the way its done :)

Edit: I've done it in the following way: https://stackoverflow.com/a/9290723/969325

This is for views but could be used for fragments as well.

like image 118
Warpzit Avatar answered Oct 17 '22 21:10

Warpzit