I am trying to transition between two fragments using this animation.
Problem I have is when I transition using the following code. The animation slides in the new fragment over a white background instead of the old fragment.
I want to either use .replace or create the exact same functionality as replace. I also want the animation to slide the new fragment over the old fragment.
FragmentTransaction transaction = MainActivity.instance.getSupportFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_right, R.anim.slide_in_right, R.anim.slide_out_right);
transaction.replace(R.id.main_frame_content, fragment);
transaction.commit();
try {
fragmentManager.executePendingTransactions();
} catch (Exception e) {
}
Animations:
Slide in right:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:fromXDelta="100%p"
android:toXDelta="0" />
</set>
slide out right:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="0"
android:toXDelta="100%p" />
</set>