简体   繁体   中英

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

在此处输入图像描述

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!

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>

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM