我在 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()
他们没有解决我的问题。