Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove right padding/margin to a TextInputLayout prefix

TextInputLayout prefix has a small but noticeable spacing to the subsequent text in the TextInputEditText.

In the following image, The first www is the prefix, the following are the regular text. I want to remove the spacing shown in the circle

enter image description here

My code:

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/text_input_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:prefixText="www"
    app:prefixTextColor="@color/black">

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

Thank you!

like image 481
Nuno Costa Avatar asked Mar 29 '26 03:03

Nuno Costa


1 Answers

You can override the material_input_text_to_prefix_suffix_padding dimension in your dimens.xml file

Something like:

<dimen name="material_input_text_to_prefix_suffix_padding">0dp</dimen>

enter image description here

like image 198
Gabriele Mariotti Avatar answered Apr 02 '26 23:04

Gabriele Mariotti