Android Fragment 切换动画中间有间隙

public void redirectToAttachedFragment(int to, int type) {
FragmentManager fragmentManager=getFragmentManager();
FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
BaseFragment subFragment=attachedFragmentArray.get(to);

    if (type == 1) {
        fragmentTransaction.setCustomAnimations(
                R.animator.fragment_slide_left_enter,
                R.animator.fragment_slide_right_exit

        );

        //系统动画
     //  fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
    } else if (type == -1) {
            fragmentTransaction.setCustomAnimations(
                R.animator.fragment_slide_right_enter,
                R.animator.fragment_slide_left_exit
               );
    }
    fragmentTransaction.replace(R.id.flFilterSortContainer, subFragment);
    fragmentTransaction.commitAllowingStateLoss();
}

    动画代码:
    <?xml version="1.0" encoding="utf-8"?>


android:interpolator="@android:anim/decelerate_interpolator"
android:valueFrom="380dp"
android:valueTo="0dp"
android:valueType="floatType"
android:propertyName="translationX"
android:duration="200" />

动画代码:
<?xml version="1.0" encoding="utf-8"?>

android:interpolator="@android:anim/decelerate_interpolator"
android:valueFrom="0dp"
android:valueTo="-380dp"
android:valueType="floatType"
android:propertyName="translationX"
android:duration="200" />

问题来了:切换时中间有一条缝隙图片说明

实际场景中就会看到一个白块飞速闪过。是什么原因?有解吗?

2个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐