ScrollView内的MotionLayout在状态更改后不会更新高度

问题描述 投票:6回答:1

我在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仅显示View 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()

他们没有解决我的问题。

android android-scrollview android-motionlayout
1个回答
0
投票

不幸的是,我也遇到了这样的问题,但是找到了解决方法

© www.soinside.com 2019 - 2024. All rights reserved.