EditText material construct adds incorrect padding
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 image on a pre-Lollipop as well as a Lollipop device.
How can I compensate for unnecessary filling EditText
?
I would add android:paddingLeft
to denote a TextView, but I donβt know what value I should specify.
source to share
Theme.AppCompat
uses @drawable/abc_edit_text_material.xml
as background EditText
. From sources I can see what it is InsetDrawable
. InsetDrawable
has its own "paddings" - @dimen/abc_control_inset_material
. To compensate for these spacers, I add android:paddingLeft="@dimen/abc_control_inset_material"
to the notch 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 if this is the definitive answer because it is not documented.
source to share
Create several dimens.xml files with different values ββ- XY folders, where XY is the API level, i.e 18
. : .
The actual values ββare taken from this file: android:paddingRight="@dimen/...
If you want to use the default API level values, then:
In the SDK folder for each API level, you will find the file size in the values ββfolder.
Take each of these files and copy them into your folders with different meanings.
source to share