ScrollView中的ConstraintLayout,constraintHeight_percent中断滚动

时间:2018-12-18 17:18:07

标签: android android-scrollview android-constraintlayout

我有这样的XML布局和ScrollView,并且其中只有子ConstraintLayout。然后,在此ConstraintLayout中通常有几个带有包装内容的子视图。但是我想使用“约束布局”的子视图之一来填充80%的屏幕,因此我尝试使用 app:layout_constraintHeight_percent ,但它中断了滚动。似乎视图确实具有80%的高度,但其余内容恰好占据了其余20%的高度,并且适合屏幕高度,因此自定义视图下方的其他视图将被忽略。

<ConstraintLayout>
<ScrollView
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_margin="0dp"
        android:fillViewport="true"

        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent">

        <android.support.constraint.ConstraintLayout
            android:id="@+id/calendarBackgroundLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        <!-- child views with wrap content --> 

        <com.mydomain.CustomView
                android:id="@+id/myCustomView"
                android:layout_width="0dp"
                android:layout_height="0dp"

                android:layout_marginTop="8dp"
                android:layout_marginStart="16dp"
                android:layout_marginEnd="16dp"

                app:layout_constraintHeight_percent="0.8"
                app:layout_constraintDimensionRatio="h,5:8"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toBottomOf="@id/view_above_this" />

        <!-- additional child views with wrap content --> 
</ConstraintLayout>
</ScrollView>
</ConstraintLayout>

0 个答案:

没有答案