'Include androidx.constraintlayout.helper.widget.Flow in layout file

Rather than writing same code in every page, I need to have it somewhere in a layout file and include it in other files.

I have tried this and failed:

flow.xml::

<?xml version="1.0" encoding="utf-8"?>
<layout     xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    >
    <androidx.constraintlayout.helper.widget.Flow
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        app:layout_constraintStart_toStartOf="parent"
        />
</layout>

anotherLayoutFile.xml::

<include  android:id="@+id/ll1"
    layout="@layout/content_cons_flow"
    app:layout_constraintTop_toTopOf="parent"
    app:constraint_referenced_ids="tvName,etName"
    />


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source