Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Fragment Transaction with animation causes white flash

I have two fragments. Fragment A is initially in view. When the user presses a button Fragment B is animated up into view using the method below. When I pop fragment B it animates back down out of view but right as it finishes the screen flashes white. Not sure what is causing this, only seems to happen on kit-kat not on lollipop. The animations being used are slide up and slide down animations defined in xml.

@Override
public void loadFragment(BaseFragment fragment, boolean replace, boolean addToBackStack, int animIn, int animOut, int animPopIn, int animPopout) {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    if (animIn != -1 && animOut != -1 && animPopIn != -1 && animPopout != -1) {
        transaction = transaction.setCustomAnimations(animIn, animOut, animPopIn, animOut);
    } else if (animIn != -1 && animOut != -1) {
        transaction = transaction.setCustomAnimations(animIn, animOut);
    }

    if (replace) {
        transaction = transaction.replace(R.id.container, fragment);
    } else {
        transaction = transaction.add(R.id.container, fragment);
    }

    if (addToBackStack) {
        transaction = transaction.addToBackStack(null);
    }

    transaction.commit();
}
like image 721
Nath5 Avatar asked Mar 24 '15 18:03

Nath5


1 Answers

For me this crash animations of bottomBarNavigation, NavigationDrawer and when I use replace fragment

<FrameLayout
            android:id="@+id/container"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <!--android:animateLayoutChanges="true" //THIS LINE CRASH THE ANIMATIONS-->
like image 196
n1rocket Avatar answered Nov 17 '22 02:11

n1rocket