RelativeLayout: wrap_content не соблюдается - PullRequest
0 голосов
/ 26 ноября 2018

Почему RelativeLayout не переносит содержимое?Если я удаляю последнее представление, которое выравнивается по нижнему родителю, оно работает ...

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="3dp"
        android:layout_marginBottom="@dimen/persistent_buttons_area_height"
        android:paddingBottom="8dp">

        <com.xxx.ui.presentation.VerticalNestedScrollview
            android:id="@+id/scroll_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dp"
            android:paddingBottom="11dp"
            android:clipToPadding="false"
            android:overScrollMode="never">

            <androidx.appcompat.widget.AppCompatTextView
                android:id="@+id/description"
                style="@style/PresentationDescription"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal" />

        </com.xxx.ui.presentation.VerticalNestedScrollview>

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/keyline_1"
            android:layout_alignParentTop="true"
            android:background="@drawable/list_top_gradient_dark"/>

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/keyline_1"
            android:layout_alignParentBottom="true"
            android:background="@drawable/list_bottom_gradient_dark"/>

    </RelativeLayout>

Текущий результат (в красном прямоугольнике - RelativeLayout):

enter image description here

Так можно ли правильно обернуть содержимое для этого RelativeLayout?

Большое спасибо, ребята!

1 Ответ

0 голосов
/ 26 ноября 2018

Как это могло бы быть, потому что вы используете View с android:layout_alignParentBottom="true", теперь то, что он делает, это выравнивает этот вид по основанию относительного макета, теперь RelativeLayout высота равна wrap_content это не будетработать, потому что android:layout_alignParentBottom="true", который заставляет относительное расположение использовать столько места, доступно.

Так что Возможное решение может быть: добавьте android:layout_below="@+id/scroll_view" и удалите android:layout_alignParentBottom="true" из View, который находится внизу экрана.

...