Макет элемента RecyclerView, который использует constraintLayout как root макет, невидимый, когда RecyclerView в ConstraintLayout - PullRequest
0 голосов
/ 09 марта 2020

Элемент RecyclerView использует constraintLayout в качестве root макета.

Элемент RecyclerView использует constraintLayout в качестве root макета. Он содержит только TextView.

<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/tvInRv"
        android:layout_width="0dp"
        android:layout_height="48dp"
        android:gravity="center"
        android:textColor="@color/colorPrimary"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:text="Hello world" />

</android.support.constraint.ConstraintLayout>

RecyclerView в ConstraintLayout

<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
    android:layout_height="match_parent"
    tools:context=".findviewbyid.FindViewByIdActivity">


    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv"
        android:layout_width="0dp"
        android:layout_height="200dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

Затем элементы не отображаются, пока я не прокручиваю RecyclerView.

...