2016-12-15 12 views
0

フラグメントトランザクションを実行中に、スライドインレットとスライドアウトの正しいアニメーションを挿入しようとしています。アニメーションが適切に動作しています。しかし、私はフラグメントをアニメートしながら白い画面を取得しています。私はgoogleで与えられたすべての解決策に疲れました。しかし、彼らのどれも働いていませんでした。これは私が現在やっていることです。容器内のフラグメントを交換フラグメントのアニメーション中に白い画面が表示される

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

は:enter, exit, popEnter, popExitが参照

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

- 私はクロームカスタムタブの同じ遷移を適用する場合>

R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_rightは、移行は非常に滑らかでした。白い画面はありませんでした。白い画面がフラグメントトランザクションでのみ表示されるのはなぜですか?私は同じ問題を抱えていたアドバンス

答えて

0

感謝。透明な背景をframelayoutに変更してみてください。

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

親切!

関連する問題