3

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>
Darren
  • 75
  • 6
  • 2
    Still looking for an answer, any help will be appreciated – Darren Mar 20 '19 at 13:18
  • same problem. @Darren if you solved this problem, please, share your implementation) – Scrobot Sep 24 '19 at 17:33
  • Something similar and potentially applicable: https://stackoverflow.com/questions/33561523/remove-the-white-screen-a-slide-window-transition-creates-when-it-starts – Goran Devs Mar 04 '20 at 13:15

0 Answers0