Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Padding between divider line and error text in TextInputLayout

How can I set the padding between the divider line and the error text (marked with the question mark in the image) in a TextInputLayout? I tried adding the padding in the style specified as errorTextAppearance but it had no effect.

enter image description here

EDIT: Here's the layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="test.textinputlayouttest.MainActivity">

    <android.support.design.widget.TextInputLayout
        android:id="@+id/address"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:errorEnabled="true"
        app:errorTextAppearance="@style/Error">

        <EditText
            android:id="@+id/username"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Enter address"
            android:inputType="textEmailAddress"
            android:padding="26dp"/>
    </android.support.design.widget.TextInputLayout>

</android.support.constraint.ConstraintLayout>

and the style:

<style name="Error" parent="TextAppearance.AppCompat">
    <item name="android:textColor">@color/red</item>
    <item name="android:paddingBottom">300dp</item>
</style>
like image 539
buellas Avatar asked Dec 23 '22 10:12

buellas


1 Answers

if you need padding only between the divider line and the error text

use the previous example just change android:padding="26dp" to - > android:layout_marginBottom="20dp"

<android.support.design.widget.TextInputLayout
                android:id="@+id/usernameWrapper"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <EditText
                    android:layout_marginBottom="20dp"
                    android:id="@+id/username"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textEmailAddress"
                    android:hint="Username"/>

            </android.support.design.widget.TextInputLayout>
like image 131
Ali Asadi Avatar answered Dec 27 '22 01:12

Ali Asadi