3

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!

3
  • stackoverflow.com/questions/41403193/… Commented Nov 23, 2022 at 11:14
  • @SaifulSazib the edittext padding itself is fine, it's the prefix's right padding inside the edittext which is giving me headaches Commented Nov 23, 2022 at 11:18
  • This might help. create a custom class. rrohaill.medium.com/… Commented Nov 23, 2022 at 16:36

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

0

This

inputLayout.prefixTextView .updateLayoutParams<MarginLayoutParams> { updateMarginsRelative(end = YOUR_VALUE) } 

might be an option.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.