Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Android Lists and Adapters Displaying Lists of Data Binding Data in the Activity

Arturo Castro
Arturo Castro
1,711 Points

I got an error in the xml file, it says: Element android.support.constraint.ConstraintLayout is not allowed here

After I copied and pasted the instructions on Android Studio I got an error that says: Element android.support.constraint.ConstraintLayout is not allowed here. Im using Android Studio 3.6 and cant find a solution on the internet.

2 Answers

can I see your code?

Arturo Castro
Arturo Castro
1,711 Points

Thanks Xander for the Reply. This is my code: https://ibb.co/MpvMkzv

Arturo Castro
Arturo Castro
1,711 Points

And this is the full code:

<?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" xmlns:tools="http://schemas.android.com/tools"> <data> <variable name="hour" type="com.example.stormy.weather.Hour"/> </data> <android.support.constraint.ConstraintLayout android:id="@+id/coordinatorLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/appBackground" tools:context=".ui.HourlyForecastActivity">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/hourlyListItems"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>

</layout>

here is my code. I used the androidx support package to get mines to work

<androidx.constraintlayout.widget.ConstraintLayout

    android:id="@+id/coordinatorLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/appBackground">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/hourlyListItems"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="1.0" />
</androidx.constraintlayout.widget.ConstraintLayout>