Search code examples
androidandroid-support-libraryandroid-textinputlayoutmaterial-componentsmaterial-components-android

what's wrong in my xml code? I want to make a TextInputLayout but can't


what's wrong in my xml code? I want to make a TextInputLayout but can't. can you help what should i do to make TExtInputLayout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"    
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:Layout_marginTop="20dp"
        android:Layout_marginBot="20dp"
        android:layout_marginLeft="20dp"
        android:Layout_marginRight="20dp"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.widget.support.design.TextInputLayout
            android:layout_width="match parent"
            android:layout_heigth="wrap_content"
            android:drawableStart="@drawable/ouuu"
            android:id="@+id/etnama"
            android:hint"nama anda">

       </android.widget.support.designt.TextInputLayout>

    </LinearLayout>

</LinearLayout>

Solution

  • With the design support library to use the TextInputLayout you have to add the TextInputEditText.
    Something like:

    <android.support.design.widget.TextInputLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:id="@+id/etnama"
             ...>
    
         <android.support.design.widget.TextInputEditText
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 />
    
     </android.support.design.widget.TextInputLayout>
    

    With androidx libraries you have to add the Material Components library and use:

    <com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ...>
    
      <com.google.android.material.textfield.TextInputEditText
          android:layout_width="match_parent"
          android:layout_height="wrap_content"/>
    
    </com.google.android.material.textfield.TextInputLayout>