Контейнер ошибок TextInputLayout имеет большую высоту. Я хочу уменьшить его высоту. Как я могу это сделать?
<android.support.design.widget.TextInputLayout
android:id="@+id/textInput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/md_red_100"
android:layout_centerInParent="true"
app:errorEnabled="true"
android:padding="0dp"
app:hintEnabled="false">
<EditText
android:id="@+id/edittext"
style="@style/purpleNormalEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:maxLines="1"
android:paddingBottom="10dp"
android:paddingRight="50dp"/>
</android.support.design.widget.TextInputLayout>
спасибо
Я ненавижу хаки, но я не нашел надежного способа изменить высоту текста ошибки в TextInputLayout
. Поэтому я предлагаю мягкое решение:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="72dp"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-10dp"
app:errorEnabled="true">
<com.panera.bread.common.views.PaneraEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Generic Hint"
android:inputType="text"
android:maxLines="1" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
Я получаю желаемую высоту для моего TextInputLayout
, похлопывая ее по LinearLayout
с закрепленной высотой. Мой TextInputLayout
обертывает его содержимое для высоты и затушевывает тяжелое заполнение ошибки, устанавливая отрицательное нижнее поле.