6

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

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Askiip
  • 61
  • 2

4 Answers4

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>
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
0

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

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>
0

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

Preeti
  • 11
  • 2