I have an activity which has a fragment loaded in it's FrameLayout by default. And I have set the fragment's enter and exit transition as follows:
HomeFragment homeFragment = new HomeFragment();
homeFragment.setEnterTransition(enter);
homeFragment.setExitTransition(exit);
getSupportFragmentManager().beginTransaction().replace(R.id.vg_full_container,homeFragment).commitAllowingStateLoss();
But when my activity starts up, the fragment doesn't show any transition.
However if I make use of FragmentTransaction's setCustomAnimation()
, the fragment animates into the screen. Also the fragments whose loading is triggered by some event such as OnClick()
etc., on the same activity, transitions into the screen withsetEnterTransition()
and setExitTransition()
. But the activity's defaultly loaded fragments don't transition or at least I can't see any transition happening. Also, I have not set any enter and exit transitions on the activity that loads this fragment.
How do I get the defaultly loaded fragments to transition with setEnterTransition()
and setExitTransition()
?
Following is the transition XML file:
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<slide
android:duration="400"
android:slideEdge="left" />
<targets>
<target android:excludeId="@id/toolbar"/>
<target android:excludeId="@id/collapsing_toolbar"/>
<target android:excludeId="@id/transaction_toolbar"/>
<target android:excludeId="@id/tab_layout"/>
</targets>
</transitionSet>