造成的原因是因为在返回时onResume方法会进行一个共享元素的Alpha赋值,会先赋值为0,再到1,所以会有明显的闪屏。

修改方式:

在闪屏页面添加callback

setExitSharedElementCallback(new TransitionCallBack());

@TargetApi(Build.VERSION_CODES.LOLLIPOP)

public class TransitionCallBack extends SharedElementCallback {

@Override

public Parcelable onCaptureSharedElementSnapshot(View sharedElement, Matrix viewToGlobalMatrix, RectF screenBounds) {

sharedElement.setAlpha(1);

return super.onCaptureSharedElementSnapshot(sharedElement, viewToGlobalMatrix, screenBounds);

}

}

就不会在闪屏了。

具体分析参考:

https://www.jianshu.com/p/7664527930e1

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐