android 共享元素动画闪烁,Android 共享元素动画,返回时会闪一下的问题
造成的原因是因为在返回时onResume方法会进行一个共享元素的Alpha赋值,会先赋值为0,再到1,所以会有明显的闪屏。修改方式:在闪屏页面添加callbacksetExitSharedElementCallback(new TransitionCallBack());@TargetApi(Build.VERSION_CODES.LOLLIPOP)public class TransitionC
造成的原因是因为在返回时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
更多推荐
所有评论(0)