android - ScrollView里面的MotionLayout在状态改变后不更新高度
问题描述
我在 NestedScrollView 中有一个 MotionLayout:
<androidx.core.widget.NestedScrollView
android:id="@+id/scroll_content"
android:layout_width="match_parent"
android:fillViewport="true">
<androidx.constraintlayout.motion.widget.MotionLayout
android:id="@+id/content_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
app:layoutDescription="@xml/main_scene">
<View 1>
<View 2>
<View 3>
</androidx.constraintlayout.motion.widget.MotionLayout>
我的状态 1 仅显示视图 1。
我的状态 2 仅显示视图 2。
我的状态 3 显示视图 1 + 视图 2(在视图 1 下方)+ 视图 3(在视图 2 下方)
由于状态 3 垂直附加多个视图,因此它是垂直最长的。
但是,我只能向下滚动到为状态 1 和状态 2 设置的数量。它不会重置 scrollView 内的高度。
难道我做错了什么?
我在 onTransitionCompleted() 尝试了以下操作:
scroll_content.getChildAt(0).invalidate()
scroll_content.getChildAt(0).requestLayout()
scroll_content.invalidate()
scroll_content.requestLayout()
他们没有解决我的问题。
解决方案
motion:layoutDuringTransition="honorRequest"
在XML 文件中添加<Transition>
可以解决问题。layoutDescription
这是ConstraintLayout
在版本中添加的2.0.0-beta4
推荐阅读
- numpy - TensorFlow 2.2.0:layer.Flatten 不起作用
- javascript - node.js mysql查询似乎不需要等待
- kubernetes - Kubernetes Undo 终止 PV
- vapor - 如何将蒸汽 4 降级为蒸汽 3?
- r - plot_ly() 和闪亮:改变交互环境中区域填充的透明度
- angular - Angular 中的高阶 Observable 多个任务
- java - 错误:无法将 java.lang.String 类型的值转换为 int
- angular - 如果使用 object.value 而不是 object,则角度递归模板列表将变为无限递归
- nspredicate - 具有 2 个值的 NSPredicateRow(例如“介于”)
- go - Go 中的错误处理:何时忽略错误?