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”等变量,即可能影响过渡效果的属性。有可能还存在其它因素导致表现某些异常。最后,应设法通过试错来找出导致视图闪烁的实际原因并进行修复。

相关内容

热门资讯

三分钟绝活儿!wpk辅助购买(... 三分钟绝活儿!wpk辅助购买(透视)好像是真的有辅助辅助(哔哩哔哩)1、wpk辅助购买辅助器安装包、...
六分钟模板!大菠萝辅助器(透视... 六分钟模板!大菠萝辅助器(透视)其实真的有辅助工具(哔哩哔哩)运大菠萝辅助器辅助工具,进入游戏界面。...
第8分钟办法!wepoker透... 第8分钟办法!wepoker透视脚本(透视)原来真的是有辅助开挂(哔哩哔哩)1、wepoker透视脚...
第二分钟积累!newpoker... 第二分钟积累!newpoker脚本(透视)果然存在有辅助工具(哔哩哔哩)newpoker脚本透视方法...
第4分钟攻略!德州来玩辅助器(... 第4分钟攻略!德州来玩辅助器(透视)本来真的有辅助下载(哔哩哔哩)小薇(辅助器软件下载)致您一封信;...
6分钟绝活儿!aapoker怎... 6分钟绝活儿!aapoker怎么控制牌(透视)好像有辅助开挂(哔哩哔哩)1、aapoker怎么控制牌...
七分钟指南书!aapoker破... 七分钟指南书!aapoker破解侠是真的吗(透视)原来存在有辅助教程(哔哩哔哩)暗藏猫腻,小编详细说...
第3分钟法门!智星德州插件(透... 第3分钟法门!智星德州插件(透视)好像真的有辅助辅助(哔哩哔哩)1、下载好智星德州插件脚本下载之后点...
1分钟机巧!wepoker到底... 1分钟机巧!wepoker到底有没有透视(透视)果然是有辅助开挂(哔哩哔哩)1、下载好wepoker...
7分钟学习!wepoker养号... 7分钟学习!wepoker养号规律(透视)总是有辅助辅助(哔哩哔哩)1)wepoker养号规律免费钻...