8

Mam dwa fragmenty. Fragment A jest początkowo w widoku. Kiedy użytkownik naciśnie przycisk Fragment B jest animowany do widoku za pomocą poniższej metody. Po pobraniu fragmentu B animacja znika z widoku, ale po jego zakończeniu ekran miga na biało. Nie jestem pewien, co jest przyczyną tego, wydaje się, że dzieje się tylko na kit-kat, nie na Lollipop. Użyte animacje to animacje poślizgu i slajdu zdefiniowane w xml.Fragment Androida Transakcja z animacją powoduje biały błysk

@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(); 
} 

Odpowiedz

1

dla mnie to katastrofa animacje bottomBarNavigation, NavigationDrawer i kiedy używać zastąpić 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--> 
Powiązane problemy