1

私は、フラグメントの移行のために、このコードを使用しています:アンドロイド8.1フラグメントsetExitTransitionバグ

Transition transition = new Fade(); 
transition.addTarget(recyclerView); 
setExitTransition(transition); 

をしかし、私は、Android 8.1 API 27でこのコードを実行すると、今、ビューが削除され、フラグメントへの復帰後に見えてくるのdoesnt。 27 APIで

答えて

0

は、今では、以前のSceneの階層Viewから削除するビューを伴うこと、ViewGroupOverlayViewを追加、変更方法TransitionUtils.createViewBitmapました。どのようにこの結果が副作用を引き起こすか、この方法は除去をバイパスするように設計されているので、View

ドキュメントでは、Sceneがレイアウトリソースファイルから作成された場合にのみ、Viewを親から削除することができます。

もっと詳しくVisibility.onDisappear

この使用してみてください:

@TargetApi(19) 
public class FadeSafeOreo extends Fade { 

    public FadeSafeOreo() { 
     super(); 
    } 

    public FadeSafeOreo(int fadingMode) { 
     super(fadingMode); 
    } 

    @TargetApi(21) 
    public FadeSafeOreo(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 

    @Override 
    public Animator onDisappear(ViewGroup sceneRoot, TransitionValues startValues, int startVisibility, TransitionValues endValues, int endVisibility) { 
     RemovedView removedView = null; 
     boolean existStart = startValues != null && startValues.view != null; 
     boolean existEnd = endValues != null && endValues.view != null; 
     if (Build.VERSION.SDK_INT >= 27 && !canRemoveViews() && existStart && !existEnd) { 
      removedView = new RemovedView(startValues.view); 
     } 
     Animator animator = super.onDisappear(sceneRoot, startValues, startVisibility, endValues, endVisibility); 
     if (removedView != null) removedView.append(); 
     return animator; 
    } 

    private static class RemovedView { 
     private View view; 
     private ViewGroup parent; 
     private int position = -1; 

     private RemovedView(View view) { 
      this.view = view; 

      if (view != null && view.getParent() instanceof ViewGroup) { 
       parent = (ViewGroup) view.getParent(); 
       for (int i = 0, count = parent.getChildCount(); i < count; i++) { 
        if (parent.getChildAt(i) == view) { 
         position = i; 
         return; 
        } 
       } 
      } 
     } 

     private void append() { 
      if (view != null) { 
       if (parent != null) { 
        if (view.getParent() != parent && position >= 0) { 
         parent.addView(view, position); 
        } 
        parent = null; 
       } 
       view = null; 
      } 
     } 
    } 
} 
+0

をしかし、これは大規模なビットマップを作成する場合にのOutOfMemoryの問題を解決していません。しかし誰も気にしないようだ) – Yanbaev

関連する問題