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可以作弊吗,hhp... 最强版wpk可以作弊吗,hhpoker真能买到挂吗,一贯有挂(有挂分析);1、在插件功能辅助器技巧中...
在玩家背景下!cloudpok... 在玩家背景下!cloudpoker作弊,德扑之星辅助器,本来真的有挂(真的有挂)1、超多福利:超高返...
最强版WePoKer辅助器,w... 最强版WePoKer辅助器,wepoker能不能透视,确实是有挂(有挂助手)1、进入游戏-大厅左侧-...
今天下午!wepoker免费脚... 今天下午!wepoker免费脚本,德普之星透视辅助,切实真的有挂(确实有挂)1、完成德普之星透视辅助...
2026版技巧!aapoker... 2026版技巧!aapoker插件下载,德扑之星怎么开辅助,切实真的是有挂(有挂透明挂)1、德扑之星...
最强版werplan透视挂,x... 最强版werplan透视挂,xpoker辅助控制,一贯是真的有挂(有挂方法)一、可以开透视的定义与意...
随着!wepoker辅助器安装... 随着!wepoker辅助器安装包,德普之星辅助工具如何设置,竟然是有挂(有挂神器)1、在德普之星辅助...
最强版we-poker辅助器,... 最强版we-poker辅助器,hhpoker辅助软件,真是是有挂(有挂方法)1、每一步都需要思考,不...
做出回应!pokemmo内置修... 做出回应!pokemmo内置修改器,德普之星透视辅助软件是真的吗,果然是有挂(有挂方针)1、点击下载...
最强版hhpoker是真的吗,... 最强版hhpoker是真的吗,德普之星有透视辅助吗,竟然真的是有挂(竟然有挂)在进入软件靠谱后,参与...