How to disable padding on TextInputLayout?

dazza5000 picture dazza5000 · Dec 30, 2016 · Viewed 15.3k times · Source

There appears to be left padding automatically added when using a TextInputLayout to wrap an EditText as you can see in the screenshot below.

enter image description here

There is no padding added to the EditText in the layout XML, but when the view is rendered there appears to be left padding on the EditText. You can see this when comparing the TextView below the TextInputLayout.

How do I disable this left padding from being added?

Thank you!

Answer

Andrew Orobator picture Andrew Orobator · Jul 10, 2019

You can just set the start and end padding on the inner EditText to 0dp.

<com.google.android.material.textfield.TextInputLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content">

  <com.google.android.material.textfield.TextInputEditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingStart="0dp"
    android:paddingEnd="0dp" />

</com.google.android.material.textfield.TextInputLayout>

Here's a screenshot with Show Layout Bounds turned on so you can see that the hints go all the way to the edge of the view.

EditTextNoPadding