Sorry custom animations are broken when popping the back stack. This will be fixed in a future release. Until then, you just won't be able to do this -- you will need to either stick with the standard transitions, or manually add/remove the fragments yourself.
On Tue, Mar 22, 2011 at 3:32 PM, Kelly Merrell < kmerr...@mercuryintermedia.com> wrote: > Related bug report here: > > http://code.google.com/p/android/issues/detail?id=15623&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars > > On Mar 16, 9:54 am, Kelly Merrell <kmerr...@mercuryintermedia.com> > wrote: > > Hi All, > > I am having trouble using or understanding how popping > > FragmentTransactions off of the back stack handles the custom > > animations. Specifically, I expect it to call the "out" animation, but > > it doesn't seem to. > > > > I have a simple method to handle a fragment transaction > > (FragmentTransaction) where I add a fragment and apply a custom > > transition so that it will fade-in/fade-out. I am also adding this to > > the back stack so that the user can undo that transaction with the > > back button, essentially navigating to the state before the fragment > > was added. > > > > Everything works great moving forward, but when the user clicks the > > back button, the transition animations do not reverse. What I expected > > was that when the fragment got removed, it would use the fade out > > animation. Instead it seems to pop out (without animation) and then > > the container seems to fade in. I'm not sure that this is exactly what > > is happening, but the fragment is definitely not fading out. > > > > Here is the method that handles the transaction: > > > > protected void changeFragment() { > > FragmentTransaction ft = fm.beginTransaction(); > > ft.setCustomAnimations(android.R.anim.fade_in, > > android.R.anim.fade_out); > > ft.add(R.id.fragment_container, new TestFragment()); > > ft.addToBackStack(null); > > ft.commit(); > > > > } > > > > My application uses the compatibility library to add fragment support, > > but I assume this to be applicable to Honeycomb (android-11) as well. > > > > Does anyone know if I am just doing something wrong here or if I am > > just expecting too much? Ideally, I would like to animate the > > fragments similarly to how Gmail (on the Xoom) does in regards to > > moving forward by clicking a message and then back by using the back > > button. Preferably not having to override the back button > > functionality and keep up with my own fragment state since I could > > have several "transactions" that I would want to back out of and I am > > not a fan of re-inventing wheels. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en