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

相关内容

热门资讯

开挂透视!hhpoker是正品... 开挂透视!hhpoker是正品吗,微乐河南家乡麻将辅助脚本,技法教程(有挂攻略)-哔哩哔哩1、玩家可...
专业透视!哈糖大菠萝可以开挂吗... 专业透视!哈糖大菠萝可以开挂吗,微信微乐辅助器下载,积累教程(有挂总结)-哔哩哔哩1、哈糖大菠萝可以...
详情透视!wejoker辅助器... 详情透视!wejoker辅助器要钱玩吗,微信小程序微乐辅助器,机巧教程(真的有挂)-哔哩哔哩暗藏猫腻...
详细透视!wepoker有透视... 您好,wepoker有透视底牌吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【48527505...
科普透视!aapoker怎么选... 科普透视!aapoker怎么选牌,微乐斗地主有挂吗,指南书教程(有挂存在)-哔哩哔哩1、进入游戏-大...
专业透视!pokerrrr2辅... 专业透视!pokerrrr2辅助,微信卡五星小程序辅助,诀窍教程(了解有挂)-哔哩哔哩1.poker...
关于透视!德普之星透视免费,微... 关于透视!德普之星透视免费,微乐游戏小程序脚本,妙招教程(有挂解惑)-哔哩哔哩1、进入到德普之星透视...
了解透视!德普之星透视辅助,微... 了解透视!德普之星透视辅助,微乐自建房辅助工具在哪,课程教程(有挂规律)-哔哩哔哩1、完成德普之星透...
揭露透视!德普之星透视辅助软件... 揭露透视!德普之星透视辅助软件激活码,微乐小程序辅助工具2025,攻略教程(竟然有挂)-哔哩哔哩一、...
分享透视!hhpoker智能辅... 分享透视!hhpoker智能辅助插件,手机微信小程序游戏破解器下载,绝活儿教程(果真有挂)-哔哩哔哩...