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

相关内容

热门资讯

黑科技攻略(wepoke辅助机... 黑科技攻略(wepoke辅助机器人)外挂透明挂辅助方法(透视)本来是有挂(黑科技规律)1、进入游戏-...
辅助黑科技(wpk透视辅助)外... 辅助黑科技(wpk透视辅助)外挂黑科技辅助软件(透视)好像真的是有挂(黑科技脚本);进入游戏-大厅左...
黑科技ai(智星德州菠萝怎么看... 黑科技ai(智星德州菠萝怎么看有没有开挂)外挂透视辅助助手(透视)果然有挂(黑科技工具);1、智星德...
黑科技新版(aapoker猫腻... 黑科技新版(aapoker猫腻)外挂透视辅助器(透视)本来真的有挂(黑科技揭秘)1、游戏颠覆性的策略...
黑科技辅助(德州之星透牌器)外... 黑科技辅助(德州之星透牌器)外挂透明挂辅助助手(透视)一直是有挂(黑科技细节)1、完成德州之星透牌器...
黑科技辅助挂(微扑克有辅助挂)... 黑科技辅助挂(微扑克有辅助挂)外挂黑科技辅助安装(透视)原来真的是有挂(黑科技黑科技)1、微扑克有辅...
黑科技app(微扑克全自动机器... 黑科技app(微扑克全自动机器人)外挂透明挂辅助安装(透视)本来真的是有挂(黑科技辅助)1、用户打开...
黑科技辅助挂(WePoKe有挂... 黑科技辅助挂(WePoKe有挂吗)外挂透明挂辅助助手(透视)果然是有挂(黑科技攻略)1、玩家可以在W...
黑科技代打(德州ai辅助器)外... 黑科技代打(德州ai辅助器)外挂黑科技辅助挂(透视)其实真的有挂(黑科技细节)1、每一步都需要思考,...
黑科技ai(微扑克wpk透视辅... 黑科技ai(微扑克wpk透视辅助在哪下)外挂黑科技辅助助手(透视)切实是真的有挂(黑科技教程)1、实...