Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Support library: FragmentTransaction animations not working

I'm using Peter Doyle's android-support-v4-googlemaps support library for implementing an Activity that uses both Fragments and Google Maps, and can't seem to get FragmentTransaction animations to work. I've tried using the setCustomAnimations(int enter, int exit) method as well as the setTransition(int transit) method but to no avail. Anyone been able to get animations to work, or also had problems getting animations to work?

Some of the animations I tried:

setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)

setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out)

setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right)
like image 439
Adil Hussain Avatar asked Jan 26 '12 10:01

Adil Hussain


1 Answers

You should call FragmentTransaction.setCustomAnimations first and then call FragmentTransaction.replace method like this:

        FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
        ft.setCustomAnimations(R.anim.fade_out,R.anim.fade_in);
        ft.replace(R.id.fragmentDetails, detailsFrag);
like image 168
VSB Avatar answered Oct 25 '22 12:10

VSB