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

相关内容

热门资讯

透视中牌率!德普之星透视辅助软... 透视中牌率!德普之星透视辅助软件下载,智星菠萝可以辅助吗,查到实测(有挂攻略)1、系统规律教程、辅助...
透视透视!红龙poker透视,... 透视透视!红龙poker透视,wepoker透视脚本免费,终于清楚(有挂详情)1、操作简单,无需注册...
透视美元局!wepoker底牌... 透视美元局!wepoker底牌透视脚本下载,wepoker透视脚本,最新研发(有挂教程)1、很好的工...
透视软件!wpk辅助软件多少钱... 透视软件!wpk辅助软件多少钱一个,wpk透视辅助,最新技巧(有挂总结);1、首先打开wpk透视辅助...
透视能赢!智星德州菠萝插件官网... 透视能赢!智星德州菠萝插件官网,aapoker透视脚本下载,终于发现(有挂黑科技)1、进入到智星德州...
透视规律!wpk脚本是什么,h... 透视规律!wpk脚本是什么,hhpoker辅助下载,必看攻略(有挂透明);辅助器中分为三种模型:软件...
透视挂透视!智星菠萝辅助,红龙... 透视挂透视!智星菠萝辅助,红龙poker作弊指令,教程攻略(有挂教学);1)辅助挂:进一步探索辅助透...
透视app!智星菠萝辅助怎么买... 透视app!智星菠萝辅助怎么买,hhpoker辅助器,玩家实测(有挂方法)1、进入游戏-大厅左侧-新...
透视攻略!德普之星有没有挂,h... 透视攻略!德普之星有没有挂,hhpoker透视脚本下载,揭秘真相(有挂技巧);1、下载好辅助软件之后...
透视数据!aapoker透视怎... 透视数据!aapoker透视怎么用,wepoker底牌透视脚本怎样安装,玩家亲测(有挂攻略)1、完成...