layout.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView android:text="Label text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:text="Input tex"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Produces the following picture on pre-Lollipop as well as on Lollipop device.
How can I compensate the unnecessary padding of EditText?
I would add android:paddingLeft to label TextView, but I don't know which value should I specify.

Theme.AppCompat uses @drawable/abc_edit_text_material.xml as EditText background. From the sources I see that it is an InsetDrawable. InsetDrawable has it own "paddings" - @dimen/abc_control_inset_material. To compensate these paddings, I add android:paddingLeft="@dimen/abc_control_inset_material" to label's TextView.
<TextView android:text="Label text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/abc_control_inset_material"/>
I'm not sure this is a final answer, because it's not documented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With