Mohit Suthar
Mohit Suthar

Reputation: 9395

TextInputLayout remove unwanted space

I want TextInputLayout without any border and box, so I use below code for

<com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/app_name"
        app:boxBackgroundMode="none"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

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

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

but i don't know when I write

app:boxBackgroundMode="none"

to TextInputLayout then size is an automatic stretch and looks so weird if you find any solution regarding this plz help me.

Here is the screenshot of my output

enter image description here

Upvotes: 0

Views: 1202

Answers (1)

Hardik Lakhani
Hardik Lakhani

Reputation: 1564

It is because of app:boxBackgroundMode="none"

try following code to achieve your design

<com.google.android.material.textfield.TextInputLayout
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:backgroundTint="@color/white"
    app:boxStrokeColor="@color/white"
    app:boxBackgroundColor="@color/white"
    android:background="@color/white"
    android:hint="@string/app_name">

    <EditText
        android:background="@color/white"
        android:backgroundTint="@color/white"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

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

Upvotes: 1

Related Questions