Sathish
Sathish

Reputation: 519

TextInputEditText - 'padding' attribute does not apply padding to the start of the view

I am facing a strange issue in Android xml design.

Issue : As per the below block of xml of TextInputEditText, even-though a padding has been given to the view component the padding in the start is not applied. The text in the edit text is stuck to the left.

But on adding the specific paddingStart attribute to the view, the padding was applied.

 <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/editext"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:focusableInTouchMode="true"
        android:focusable="true"
        android:layout_marginTop="10dp
        android:maxLength="11"
        android:padding="16dp"
        android:text="sssssssssssss"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="parent" />

Have anyone faced this?? Can you please provide a solution to overcome this

Upvotes: 0

Views: 247

Answers (1)

Sathish
Sathish

Reputation: 519

Finally I figured out the what is causing this issue. There is a style defined globally in the project for the EditText for which paddingStart has been defined 0dp. That is why even though when the 'padding' attribute has a value.. the padding start was not considered

    <style name="EditText" parent="ThemeOverlay.MaterialComponents.TextInputEditText">
  <item name="android:paddingStart">0dp</item>
</style>

Upvotes: 1

Related Questions