This site uses cookies to deliver our services and to show you relevant ads and job listings.
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these policies and terms.

Join us in building a kind, collaborative learning community via our updated
Code of Conduct.

When i tried this it show RuntimeException: Unknown animator name: translate.
– Labeeb PanampullanFeb 8 '11 at 10:16

3

Make sure the animations defined in slide_in_left and right are constructed using a set of objectAnimator definitions rather than the old animation definition.
– Reto MeierFeb 9 '11 at 16:20

7

That helped a lot. I was on the right track but just didn't get all the way there. For the other readers, you could also have android:interpolator as an attribute, with your favorite one specified (such as "@android:interpolator/linear"). It defaults to "@android:interpolator/accelerate_decelerate".
– Dave MacLeanFeb 28 '11 at 0:44

6

I'm targeting API Level 7 with the compatability APIs. Is there a way for me to animate Fragments?
– Jarrod SmithMar 15 '12 at 21:55

5

@JarrodSmith you can try using a compatibility library like NineOldAndroids to bring the Honeycomb API down to Eclair.
– Mr. SApr 28 '12 at 14:05

The duration of the animations can be changed to any of the default values like @android:integer/config_shortAnimTime or any other number.

Note that if in between fragment replacements a configuration change happens (for example rotation) the back action isn't animated. This is a documented bug that still exists in the rev 20 of the support library.

This just saved me. Note, pay attention to the order is important, which, naturally, I missed the first time. This means you must call setCustomAnimations() before replace().
– Stephen KidsonDec 5 '13 at 20:01

3

I tried to implement on my fragments.I wrote everything as you mentioned but logcat says :unknow animator name translate How can I overcome this issue? By the way I'm calling my fragment on Navigation Drawer(Sliding Menu)
– Zafer CelalogluNov 6 '14 at 11:36

Works great but it turns out that building this with build tools 21.1 generates an error saying "Invalid file name: must contain only lowercase letters and digits ([a-z0-9_.])". I suggest editing the filenames in the answer to pop_enter.xml and pop_exit.xml.
– smichakJan 25 '15 at 7:46

Great solution and it works great when i press the back button. I just have one question: If i want to create a custom backButton, what code should i call to replicate the behaviour from the back button?
– Thomas TeilmannMar 5 '15 at 8:01

1

Thomas if you want to back, you should implemented this form: .setCustomAnimations(R.anim.pop_enter, R.anim.pop_exit, R.anim.enter, R.anim.exit)
– Alex ZaraosJun 15 '15 at 15:41

My modified support library supports using both View animations (i.e. <translate>, <rotate>) and Object Animators (i.e. <objectAnimator>) for Fragment Transitions. It is implemented with NineOldAndroids. Refer to my documentation on github for details.