Search code examples
javaandroid-studiokotlinandroid-layoutprefix

Layout attribute is not defined - Android Studio


Undeclared namespace prefix "android" (for attribute "layout_width")

How can I fix this? This says that android is not defined. How can I solve it? please help


Solution

  • try to add this in the layout

    xmlns:android="http://schemas.android.com/apk/res/android

    here is an example:

    <androidx.constraintlayout.widget.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="wrap_content"
        android:orientation="vertical">