Search code examples
androidandroid-studiomaterial-designmaterial-components-androidandroid-textinputlayout

Can remove space between box and underline for android TextInputLayout


I want to create TextInputLayout without a gap between the underline and edge of the box can remove this gap?

image here:

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:id="@+id/tilSearch"
    android:hint="@string/search_location"
    app:errorEnabled="false"
    app:errorTextColor="@color/red"
    app:helperTextEnabled="true">
    <EditText
        android:id="@+id/edtSearch"
        android:layout_width="match_parent"
        android:layout_height="@dimen/_60dp"
        android:importantForAutofill="no"
        android:inputType="text"
        tools:ignore="LabelFor" />
</com.google.android.material.textfield.TextInputLayout>

Solution

  • I've solved my issue using scaleX attribute android:scaleX="1.02". There might be some better way, but I couldn't find any.

            <com.google.android.material.textfield.TextInputLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:id="@+id/tilSearch"
                android:hint="@string/search_location"
                app:errorEnabled="false"
                app:errorTextColor="@color/red"
                app:helperTextEnabled="true">
                <EditText
                    android:id="@+id/edtSearch"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/_60dp"
                    android:importantForAutofill="no"
                    android:scaleX="1.02"
                    android:inputType="text"
                    tools:ignore="LabelFor" />
            </com.google.android.material.textfield.TextInputLayout>
    
    

    attr_android:scaleX

    This will be the result: result