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

相关内容

热门资讯

2分钟AI!WepOke辅助挂... 2分钟AI!WepOke辅助挂(透视)wepoke最新下载地址(果然真的有挂)1、这是跨平台的Wep...
9分钟安装!wepoKe辅助挂... 9分钟安装!wepoKe辅助挂(透视)cloudpoker辅助器(其实真的有挂)是一款可以让一直输的...
7分钟口控制!wepOkE辅助... 7分钟口控制!wepOkE辅助挂(透视)gg扑克平台发牌机制(一直真的有挂)您好,gg扑克,确实是有...
一分钟德州!WEPOKE辅助挂... 一分钟德州!WEPOKE辅助挂(透视)微扑克wpk辅助存在(原来真的有挂)1、超多福利:超高返利,海...
1分钟app!wepoke辅助... 1分钟app!wepoke辅助挂(透视)微扑克wpk安全(果真真的有挂);1分钟app!wepoke...
八分钟玄学!WepokE辅助挂... 八分钟玄学!WepokE辅助挂(透视)wpk俱乐部有ai(本来真的有挂)您好,WepokE,确实是有...
7分钟ai辅助!wePokE辅... 7分钟ai辅助!wePokE辅助挂(透视)德州ai智能营销系统(本来真的有挂)1、很好的工具软件,可...
八分钟技巧!wePokE辅助挂... 八分钟技巧!wePokE辅助挂(透视)wopoker用ai有用(的确真的有挂)1、超多福利:超高返利...
两分钟苹果版本!wePOke辅... 两分钟苹果版本!wePOke辅助挂(透视)aa扑克发牌机制(好像真的有挂);人气非常高,ai更新快且...
七分钟猫腻!WEPoke辅助挂... 七分钟猫腻!WEPoke辅助挂(透视)fishpoker大菠萝外挂(一直真的有挂)您好,fishpo...