Android-结束视图在材料容器转换时闪烁
创始人
2024-08-19 19:30:08
0
  1. 可能的原因是过渡使用了alpha或visibility属性来控制视图的可见性。此类属性会影响视图的透明度和占用空间。为此,应在过渡中使用additionalParameters()方法来控制透明度而不是alpha属性。例如:

val transition = MaterialContainerTransform().apply { // Set additional parameters as needed setAllContainerColors(ContextCompat.getColor(fromView.context, R.color.white)) addTarget(R.id.end_container) setInterpolator(AccelerateDecelerateInterpolator()) duration = 300L setScrimColor(Color.TRANSPARENT) }

TransitionManager.beginDelayedTransition(root, transition) findViewById(R.id.start_container).visibility = View.GONE findViewById(R.id.end_container).visibility = View.VISIBLE findViewById(R.id.end_container).alpha = 1f

  1. 另一种可能的原因是,视图在绘制过渡期间未正确调整其大小或布局。为此,应确保使用正确的布局参数来在过渡中设置视图大小和位置。例如:

val startBounds = Rect(fromView.left, fromView.top, fromView.right, fromView.bottom) val endBounds = Rect(toView.left, toView.top, toView.right, toView.bottom)

MaterialContainerTransform().apply { addTarget(toView.id) setAllContainerColors(Color.WHITE) setStartBounds(startBounds) setEndBounds(endBounds) duration = 300 }.let { TransitionManager.beginDelayedTransition(container, it) }

toView.layoutParams = frameLayoutParams.apply { width = endBounds.width() // Use the dimensions of endBounds height = endBounds.height() topMargin = endBounds.top // Align the view with endBounds leftMargin = endBounds.left }

注意:上述代码示例密切关注了到“animation”“alpha”“visibility”“fitsSystemWindows”等变量,即可能影响过渡效果的属性。有可能还存在其它因素导致表现某些异常。最后,应设法通过试错来找出导致视图闪烁的实际原因并进行修复。

相关内容

热门资讯

aapoker有猫腻!aapo... 1、aapoker有猫腻!aapoker是正规的吗,(aapokEr)好像真的是有挂,详细教程(有挂...
透视脚本!线上德州的辅助器是什... 透视脚本!线上德州的辅助器是什么,佛手在线大菠萝辅助(果然存在有挂)运线上德州的辅助器是什么辅助工具...
aapoker有猫腻!aa p... 自定义aapoker有猫腻系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器,...
透视有挂!werplan怎么透... 透视有挂!werplan怎么透视,哈糖大菠萝有没有挂(本来真的有挂);一、哈糖大菠萝有没有挂AI软件...
aapoker有挂!aapok... aapoker有挂!aapoker有挂吗,(AApOKER)一贯真的有挂,详细教程(有挂辅助挂);1...
透视私人局!werplan免费... 透视私人局!werplan免费挂下载,德州局脚本(都是存在有挂);1、werplan免费挂下载系统规...
aapoker猫腻!aapok... aapoker猫腻!aapoker外挂教程,(AAPOKeR)果然真的是有挂,详细教程(有挂辅助挂)...
透视软件!xpoker辅助器,... 透视软件!xpoker辅助器,拱趴大菠萝怎么开挂(一直有挂)1、拱趴大菠萝怎么开挂透视辅助简单,拱趴...
aapoker透视辅助!德州a... aapoker透视辅助!德州aa辅助,(aapoker)原来有挂,详细教程(有挂攻略);原来确实真的...
透视好友!聚星ai辅助工具收费... 透视好友!聚星ai辅助工具收费多少,wepoker安装教程(一贯有挂)1、在聚星ai辅助工具收费多少...