'TextInputLayout label overlapping AppCompatAutoCompleteTextView input

I'm having an issue where my TextInputLayout label is being overlapped by the input within an AppCompatAutoCompleteTextView. My apologies if this has been answered before. Here is my code snippet:

<com.google.android.material.textfield.TextInputLayout
                android:id="@+id/commission_form_category_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

<androidx.appcompat.widget.AppCompatAutoCompleteTextView
                    android:id="@+id/commission_form_category_input"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/commission_form_category_label_text"
                    android:paddingHorizontal="16dp"
                    android:paddingVertical="16dp"
                    android:text="Hello"
                    android:singleLine="true"
                    android:textSize="16sp" />

</com.google.android.material.textfield.TextInputLayout>

Here is what it looks like: overlapping text



Solution 1:[1]

Change androidx.appcompat.widget.AppCompatAutoCompleteTextView to com.google.android.material.textfield.MaterialAutoCompleteTextView and add style to TextInputLayout

here is how it looks

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/commission_form_category_container"
    android:layout_width="match_parent"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
    android:hint="Hint"
    android:layout_height="wrap_content">

    <com.google.android.material.textfield.MaterialAutoCompleteTextView
        android:id="@+id/commission_form_category_input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Hello"
        android:singleLine="true"
        android:textSize="16sp" />

</com.google.android.material.textfield.TextInputLayout>

Solution 2:[2]

Instead of paddingVertical and paddingHorizontal you can specify padding via

  • paddingTop

  • paddingStart

  • paddingEnd

  • paddingBottom

     <com.google.android.material.textfield.TextInputLayout
         android:id="@+id/commission_form_category_container"
         android:layout_width="match_parent"
         android:layout_height="wrap_content">
     <androidx.appcompat.widget.AppCompatAutoCompleteTextView
         android:id="@+id/commission_form_category_input"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:hint="@string/commission_form_category_label_text"
         android:paddingTop="24dp"
         android:paddingBottom="8dp"
         android:paddingStart="16dp"
         android:paddingEnd="16dp"
         android:text="Hello"
         android:singleLine="true"
         android:textSize="16sp" /></com.google.android.material.textfield.TextInputLayout>
    

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Aniket Patil
Solution 2 Gajendra Singh Rathore