0

I got a trouble when I do an animation between an activity and a fragment the animation for the activity is not working only the fragment move.

FragmentTransaction transaction = activity.getFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.animator.slide_in_from_left, R.animator.slide_in_from_right);
transaction.replace(R.id.main_content, fragment);
transaction.addToBackStack(null);
transaction.commit();

The activity should go on the right, but the activity don't move. I try this code for switching one fragment to another fragment and the previous fragment move on the right all works correctly. Why when I use this on activity he doesn't move ?

Vodet
  • 1,491
  • 1
  • 18
  • 36
  • 1
    You should know that Activity is contain Fragments, So that's mean only Fragments inside Activity can do the animation. – TranHieu Apr 13 '17 at 02:29
  • How can I avoid this – Vodet Apr 13 '17 at 06:19
  • with Fragments you did right things. But with Activity you could use `finish()+overridePendingTransition()` to make the animation for Activity after finished – TranHieu Apr 13 '17 at 07:10

0 Answers0