Q:

RecyclerView not showing under TextView for ConstraintLayout

I have this layout and I used ConstraintLayout. The code is below
<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/main_content"
    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=".ui.main.MainActivity">

    <TextView
    android:id="@+id/txtVwCount"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="the count is: 5"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    />

    <view
    android:id="@+id/rclrVw"
    class="androidx.recyclerview.widget.RecyclerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintTop_toBottomOf="@id/txtVwCount"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
       />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_plus"
    android:layout_margin="16dp"
    app:layout_anchor="@id/rclrVw"
    android:clickable="true"
    android:onClick="addNewTodo"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

Screenshot:

Isnt it supposed to show the textview at the top and underneath the textView it will show recyclerView? Why are they overlapping?  

A:

You need to set the android:layout_height of the RecyclerView to 0dp (also known as ConstraintLayout.MATCH_CONSTRAINT).  It's currently match_parent, so it's filling the entire parent size.

