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

相关内容

热门资讯

透视苹果版!wepoker辅助... 透视苹果版!wepoker辅助真的假的,we-poker正规吗(透视)系统教程(有挂插件)1、许多玩...
透视辅助!wepoker有辅助... 透视辅助!wepoker有辅助器吗,wepoker辅助器下载(透视)技巧教程(有挂方法)1)wepo...
透视透视!wepoker破解是... 透视透视!wepoker破解是真的还是假的,wepoker透视脚本免费使用视频(透视)德州论坛(有挂...
透视攻略!we-poker有人... 透视攻略!we-poker有人玩吗,wepoker怎么设置透视(透视)必备教程(有挂解说);1、不需...
透视私人局!wepoker分析... 透视私人局!wepoker分析,wepoker怎么挂飞机(透视)扑克教程(有挂黑科技)1、下载好we...
透视总结!wepoker买脚本... 透视总结!wepoker买脚本靠谱吗,wepoker手机版透视脚本(透视)专业教程(有挂详情)1、点...
透视新版!wepoker怎么挂... 透视新版!wepoker怎么挂底牌,wepoker免费透视(透视)可靠技巧(有挂规律);1、下载好w...
透视智能ai!wepoker怎... 透视智能ai!wepoker怎么看牌型,wepoker祈福有用吗(透视)新2025教程(有挂技巧)所...
透视教程!wepoker有辅助... 透视教程!wepoker有辅助功能吗,wepokerplus万能挂(透视)技巧教程(有挂黑科技)1、...
透视辅助!wepoker辅助器... 透视辅助!wepoker辅助器官方,wepoker辅助器软件下载(透视)技巧教程(有挂插件);一、w...