У меня есть RecyclerView
, в котором представления элементов создаются путем раздувания макета в пользовательском представлении с ConstraintLayout
в его корне.
Когда я устанавливаю дочерний вид для ширины wrap_content
, он работает нормально.
Но когда я устанавливаю второй дочерний вид для ширины 0dp
("match_constraint"), странные вещислучается.
Вот мой макет элемента:
<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="wrap_content"
>
<TextView
android:id="@+id/myTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="TextView"
/>
<TextView
android:id="@+id/myTextView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textColor="@color/text_color_dark_primary"
android:textSize="15sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/myTextView"
tools:text="TextView"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
Когда myTextView2 имеет ширину wrap_content
, все хорошо.Но когда я делаю это 0dp
, все адские разрывы освобождаются.
Проблема возникает только во втором TextView - первый TextView может иметь ширину wrap_content
или 0dp
, и оба работают должным образом.Но когда второй TextView имеет ширину 0dp
, возникают различные проблемы:
myTextView: wrap_content, myTextView1: wrap_content - без проблем
myTextView: 0dp, myTextView1: wrap_content - без проблем
myTextView: 0dp, myTextView1: 0dp - элементы не отображаются, бесконечная прокрутка
myTextView: wrap_content, myTextView1: 0dp - myTextView отображается в виде небольшого столбца в левой части экрана, остальная часть ширины равнапусто
Есть ли исправления?