Макет ограничения 0dp не рендерится должным образом - PullRequest
1 голос
/ 01 октября 2019

Вот мой xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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="match_parent"
    android:layout_height="match_parent"
    tools:showIn="@layout/activity_test">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:padding="@dimen/dp5"
        app:layout_constraintBottom_toTopOf="@+id/tiLayout"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="42dp"
        android:layout_height="42dp"
        android:layout_marginStart="5dp"
        android:layout_marginEnd="5dp"
        android:background="@drawable/shape_oval_profile"
        android:contentDescription="@string/add"
        android:padding="10dp"
        android:src="@drawable/ic_outline_info_24px"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/tiLayout"
        app:layout_constraintStart_toStartOf="parent" />

    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/tiLayout"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:hint="@string/enter_the_message"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/imageView">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/tiEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="9"
            android:fontFamily="@font/trebuchet"
            android:inputType="textMultiLine"
            android:textColor="@color/grey" />
    </com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Это дает мне следующий вывод:

enter image description here

Если я изменю TextInputLayout 's ширина до android:layout_width="wrap_content", я получаю следующий вывод,

enter image description here

Ответы [ 2 ]

0 голосов
/ 01 октября 2019

Вы должны удалить app:layout_constraintEnd_toStartOf="@+id/tiLayout" из вашего ImageView.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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="match_parent"
        android:layout_height="match_parent"
        tools:showIn="@layout/activity_test">

    <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:padding="@dimen/dp5"
            app:layout_constraintBottom_toTopOf="@+id/tiLayout"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    <ImageView
            android:id="@+id/imageView"
            android:layout_width="42dp"
            android:layout_height="42dp"
            android:layout_marginStart="5dp"
            android:layout_marginEnd="5dp"
            android:background="@drawable/shape_oval_profile"
            android:contentDescription="@string/add"
            android:padding="10dp"
            android:src="@drawable/ic_outline_info_24px"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/tiLayout"
            app:layout_constraintStart_toStartOf="parent" />

    <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/tiLayout"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:hint="@string/enter_the_message"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/imageView">

        <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/tiEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="9"
                android:fontFamily="@font/trebuchet"
                android:inputType="textMultiLine"
                android:textColor="@color/grey" />
    </com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
0 голосов
/ 01 октября 2019

Попробуйте добавить ограничения app:layout_constraintTop_toTopOf="@+id/imageView" и app:layout_constraintBottom_toBottomOf="@+id/imageView" в TextInputLayout. Сохранить высоту макета как wrap_content.

...