Android片段事务带动画会导致白色闪烁

8

我有两个片段。片段A最初在视图中。当用户按下按钮时,使用以下方法将片段B动画上移至视图中。当我弹出片段B时,它会向下动画退出视图,但就在完成时屏幕会闪烁白色。不确定是什么原因,只在kit-kat上发生,而不是在lollipop上。使用的动画是在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();
}

你找到任何解决方案了吗?我现在遇到了类似的问题。 - Georgiy Chebotarev
1个回答

1
对我来说,当我使用replace fragment时,bottomBarNavigation和NavigationDrawer的崩溃动画是个问题。
<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-->

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接