How should you implement the sort of sliding that for example the Honeycomb Gmail client uses?
Can TransactionManager
handle this automatically by adding and removing the Fragments, it's kind of difficult to test this due to the emulator being a slideshow 🙂
Best Answer
To animate the transition between fragments, or to animate the process of showing or hiding a fragment you use the
Fragment Manager
to create aFragment Transaction
.Within each Fragment Transaction you can specify in and out animations that will be used for show and hide respectively (or both when replace is used).
The following code shows how you would replace a fragment by sliding out one fragment and sliding the other one in it's place.
To achieve the same thing with hiding or showing a fragment you'd simply call
ft.show
orft.hide
, passing in the Fragment you wish to show or hide respectively.For reference, the XML animation definitions would use the
objectAnimator
tag. An example of slide_in_left might look something like this: