Problem : TextInputLayout with OutlinedBox bug with hint overlaps
Asked Answered
P

4

7

I have a problem with my hint when I want write in the EditText my hint overlaps the OutlinedBox so I don't understand what is the problem. So this my code

        <com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:errorEnabled="true"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/text_input_username"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:drawableStart="@drawable/ic_action_name"
            android:hint="@string/Enter_Username"
            android:inputType="textPersonName"/>
    </com.google.android.material.textfield.TextInputLayout>

My problem:

enter image description here

P answered 28/5, 2020 at 10:45 Comment(0)
A
8

Remove android:layout_margin="10dp" in your TextInputEditText.

enter image description here

The best solution should be:

    <com.google.android.material.textfield.TextInputLayout
        app:startIconDrawable="@drawable/...."
        android:hint="Enter_Username"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        ...>

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/text_input_username"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textPersonName"/>

    </com.google.android.material.textfield.TextInputLayout>
Amathist answered 4/8, 2020 at 19:22 Comment(0)
H
1

Does padding the text help? Perhaps padding the start of the string with some whitespaces or padding it in the xml with android:paddingLeft=5dp

Hanshaw answered 28/5, 2020 at 10:51 Comment(0)
P
0

please try to this

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/outlinedTextField"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/label"
    app:startIconDrawable="@drawable/abc_vector_test">

    <com.google.android.material.textfield.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
Publias answered 29/7, 2021 at 2:22 Comment(0)
S
0

Don't give the margin inside of textinputedittext. Please remove this android:layout_margin="10dp" and it should work fine

Sabbath answered 5/4, 2022 at 2:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.