ConstraintLayout Problems using <include>
try this Remove the <merge>
tag from both of your included layouts
<?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:layout_editor_absoluteY="81dp"
tools:layout_editor_absoluteX="0dp">
<include
android:id="@+id/includeButton"
layout="@layout/include_button_panel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<include
android:id="@+id/includeText"
layout="@layout/include_text_panel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
As Cody mentioned in comments , the problem may be that you are not setting layout_width
and layout_height
for your included layout , witch doesn't produce any editor errors , but constraints don't work any more.
Remove the <merge>
tag from both of your included layouts.
When you specifiy attributes on an <include>
tag, the system will apply those attributes to the root view of the included layout. The <merge>
tag is a special element to allow you to have multiple views in your layout without having a root view. So all of your constraints get thrown out when your included layout uses the <merge>
tag. Luckily, both of your included layouts only have one view inside the merge, so you can just remove the merge altogether.