2016-12-15 1 views
0

J'essaie de placer des animations de diapositives et de faire glisser des animations de droite tout en effectuant des transactions de fragments. L'animation fonctionne correctement. Mais, je reçois un écran blanc en animant les fragments. Je me suis fatigué de toutes les solutions possibles dans le google. Mais, aucun d'entre eux a travaillé. C'est ce que je fais actuellement.L'écran blanc apparaît lors de l'animation des fragments

/** 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> 

Remplacement Fragment dans le récipient:

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

enter, exit, popEnter, popExit se réfère à ->R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right

Lorsque j'ai appliqué la même transition pour les onglets personnalisés Chrome __gVirt_NP_NN_NNPS<__, la transition a été très lisse. Il n'y avait pas d'écran blanc. Pourquoi l'écran blanc n'apparaît que dans les transactions fragmentées.

Merci à l'avance

Répondre

0

J'ai eu le même problème. Essayez de changer un fond transparent pour votre framelayout.

<FrameLayout 
    android:id="@+id/fragmentContainer" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#00000000"/> 

Sincères salutations!