SwipeRefreshLayout не подчиняется ограничениям - PullRequest
0 голосов
/ 20 октября 2018

У меня есть SwipeRefreshLayout, содержащий RecyclerView для чата.Его нижняя часть ограничена верхней частью линейного макета в нижней части экрана:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/colorPrimaryDark"
    android:paddingLeft="0dp"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingRight="0dp"
    android:paddingBottom="0dp"
    tools:context="org.andrewedgar.theo.ChatRoomActivity">

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swiperefresh"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/listFooter"
        app:layout_constraintBottom_toTopOf="@+id/listFooter"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/chatRecyclerView"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_alignParentStart="true"
            android:layout_centerVertical="true"
            app:layout_constraintBottom_toTopOf="@+id/listFooter"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.0" />
    </android.support.v4.widget.SwipeRefreshLayout>

    <LinearLayout
        android:id="@+id/listFooter"
        android:layout_width="0dp"
        android:layout_height="40dp"
        android:layout_alignParentBottom="true"
        android:background="@drawable/custom_border"
        android:gravity="bottom"
        android:orientation="horizontal"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <EditText
            android:id="@+id/messageInput"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@android:color/transparent"
            android:ellipsize="start"
            android:gravity="center"
            android:hint="@string/prompt_msg"
            android:imeActionLabel="@string/action_send"
            android:imeOptions="actionUnspecified"
            android:inputType="textCapSentences|textAutoCorrect"
            android:maxLines="2"
            android:textColor="@color/white"
            android:textColorHint="@color/hintColor"
            android:importantForAutofill="no" tools:targetApi="o"/>

        <ImageButton
            android:id="@+id/sendButton"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@android:color/transparent"
            android:contentDescription="@string/action_send"
            android:padding="10dp"
            android:src="@android:drawable/ic_menu_send" />


    </LinearLayout>


</android.support.constraint.ConstraintLayout>

.. но SwipeRefreshLayout по-прежнему занимает весь экран, и сообщения появляются за входом сообщения:

enter image description here

Требуется ли для этого специальный тип ограничения?

1 Ответ

0 голосов
/ 20 октября 2018

Измените высоту SwipeRefreshLayout на 0dp

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swiperefresh"
    android:layout_width="match_parent"
    android:layout_height="0dp"

Почему?

Согласно документации :

Выможно установить для размера вида соотношение, например, 16: 9, если хотя бы одно из измерений вида установлено в «соответствие ограничениям» (0dp).

Также

Примечание : Вы не можете использовать match_parent для любого вида в ConstraintLayout.Вместо этого используйте «match constraints» (0dp).

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...