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智能辅助插件,wepoker透视脚本,曝光教程(有挂攻略)是由北京得wepo...
透视攻略!约局吧辅助器(透视)... 透视攻略!约局吧辅助器(透视)一贯有挂(详细辅助系统教程)1、机器人多个强度级别选择2、发牌规律人性...
总算明白!wepoker怎么下... 总算明白!wepoker怎么下载游戏,pokemmo脚本最新版,AA德州教程(有挂教程);建议优先通...
透视肯定!epoker免费透视... 透视肯定!epoker免费透视脚本(透视)原来真的是有挂(详细辅助必胜教程)1、透视辅助简单,软件透...
盘点几款!hhpoker可以控... 盘点几款!hhpoker可以控制牌吗,德州局脚本,系统教程(有挂技巧);原来确实真的有挂(需添加指定...
透视科技!wpk插件(透视)一... 透视科技!wpk插件(透视)一贯是有挂(详细辅助透牌教程)1、金币登录送、破产送、升级送、活动送。详...
研究成果!哈糖大菠萝辅助器,h... 研究成果!哈糖大菠萝辅助器,hhpoker破解工具,玩家教程(有挂攻略);科技安装教程;136704...
透视透视!德普之星私人局辅助免... 透视透视!德普之星私人局辅助免费(透视)竟然是有挂(详细辅助解密教程);1、系统规律教程、辅助透视等...
重大通报!epoker底牌透视... 重大通报!epoker底牌透视,德州透视是真的吗,可靠技巧(有挂技巧);实战中需综合运用上述技巧,并...
透视黑科技!大菠萝免费辅助器(... 透视黑科技!大菠萝免费辅助器(透视)都是真的有挂(详细辅助靠谱教程);1、首先打开最新版本,在首页我...