I'm trying to put slide-in-let and slide-out right animations while doing fragment transactions. The animation is working properly. But, I'm getting a white screen while animating the fragments. I tired with all possible solutions given in the google. But , none of them worked. This is what I'm doing currently.
/** enter_from_left.xml **/
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="-100%" android:toXDelta="0%"
android:duration="500"/>
</set>
/** enter_from_right.xml **/
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="100%" android:toXDelta="0%"
android:duration="500" />
</set>
/** exit_to_left.xml **/
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="0%" android:toXDelta="-100%"
android:duration="500"/>
</set>
/** exit_to_right.xml **/
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="0%" android:toXDelta="100%"
android:duration="500" />
</set>
Replacing Fragment in the container :
public static void replaceAndAddToBackStack(final FragmentActivity activity, final int containerId,
final Fragment fragment, String tag, int enter, int exit, int popEnter, int popExit) {
try {
FragmentTransaction transaction = activity.getSupportFragmentManager().beginTransaction();
transaction.setCustomAnimations(enter, exit, popEnter, popExit);
transaction.replace(containerId, fragment);
transaction.addToBackStack(tag);
transaction.commitAllowingStateLoss();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
where enter, exit, popEnter, popExit
refers to -> R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right
When I applied the same transition for Chrome custom Tabs, The transition was very smooth. There was no white screen. Why white screen is appearing only in fragment transactions.
Thanks in Advance