Android constraint layout not working as intended

Use this way. You are missing layout height and width for middle layout.

<include
    android:id="@+id/lay1"
    layout="@layout/empty_linear_layout"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<include
    android:id="@+id/lay2"
    layout="@layout/empty_linear_layout"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    app:layout_constraintTop_toBottomOf="@+id/lay1"
     app:layout_constraintBottom_toTopOf="@id/lay3"/>

<include
    android:id="@+id/lay3"
    layout="@layout/empty_linear_layout"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    app:layout_constraintBottom_toBottomOf="parent" />

If you want to override layout_ parameters on an <include> layout, you have to specify both layout_width and layout_height. From the developer docs:

However, if you want to override layout attributes using the <include> tag, you must override both android:layout_height and android:layout_width in order for other layout attributes to take effect.

So add these two lines to your second view:

android:layout_width="0dp"
android:layout_height="0dp"

(Note that for ConstraintLayout, 0dp means to match the constraints)


Add these lines into your middle included layout:

 <include
    android:id="@+id/lay2"
    layout="@layout/something"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintBottom_toTopOf="@+id/lay3"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/lay1" />

You were missing android:layout_width and android:layout_height attributes