Home > Software engineering >  Can remove space between box and underline for android TextInputLayout
Can remove space between box and underline for android TextInputLayout

Time:03-27

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>

CodePudding user response:

You can actually remove this underline using these attributes instead removing gap. removing gap will create double line into the layout. so instead remove that gap remove underline in the editText..

  <com.google.android.material.textfield.TextInputLayout
                android:id="@ id/tilSearch"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:hint="@string/search_location"
                app:boxBackgroundColor="@null"
                app:boxStrokeWidth="0dp"
                app:boxStrokeWidthFocused="0dp"
                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:background="@null"
                    android:importantForAutofill="no"
                    android:inputType="text"
                    tools:ignore="LabelFor" />

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

CodePudding user response:

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>

  • Related