Question Detail

I want to Animate Fragment on their Transaction I have tried this but not working.
How to set Animation on Fragment Transaction in Android?

fragmentTransaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out);


Thread Reply

Anonymous

- 1 years ago

This is Working for me

Fragment fragment = new YourFragment();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out,
        android.R.animator.fade_in, android.R.animator.fade_out);
fragmentTransaction.replace(R.id.frame_container, fragment);
fragmentTransaction.commit();

Anonymous

- 1 years ago

This is Working for me

Fragment fragment = new YourFragment();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out,
        android.R.animator.fade_in, android.R.animator.fade_out);
fragmentTransaction.replace(R.id.frame_container, fragment);
fragmentTransaction.commit();

 

Thanks for your answer