TextInputLayout seems to always have some extra padding at the top (no matter that all margins/paddings are set to 0):

The layout looks like:
<android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <android.support.v7.widget.AppCompatEditText
            android:id="@+id/txt_amount"
            style="@style/EditTextStyle"
            android:hint="@string/hint_amount"
            android:inputType="numberDecimal"/>
    </android.support.design.widget.TextInputLayout>
How to remove this extra space?
You can remove extra space above AppCompatEditText by setting app:hintEnabled="false" to TextInputLayout but it won't display hint until you re-enable that.
Now you can simply do input. setError(..) for new error and input. setErrorEnabled(false) to remove it.
TextInputLayout is a view container that is used to add more features to an EditText. It acts as a wrapper for EditText and has some features like: Floating hint. Animation that can be disabled or enabled. Error labels that display error messages when an error occurs.
You can remove extra space above AppCompatEditText by setting app:hintEnabled="false" to TextInputLayout but it won't display hint until you re-enable that.
For more info goto Android Developer site -TextInputLayout
Checkout below code
<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:hintEnabled="false">
    <android.support.v7.widget.AppCompatEditText
        android:id="@+id/txt_amount"
        style="@style/EditTextStyle"
        android:hint="@string/hint_amount"
        android:inputType="numberDecimal"/>
</android.support.design.widget.TextInputLayout>
Hope this helpfull..
@Rajesh
The accepted answer didn't work for me on version - 1.2.1 so I did some experiments and realized that the padding doesn't actually come from the TextInputLayout, rather it's from TextInputEditText. So first I removed the padding from that, but it looked uneven, so I set custom padding to TextInputEditText and it worked fine. Just add this line android:padding="16dp" to the TextInputEditText replacing 16dp with your desired value.
having a structure like this:
<com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/til_project"
                    style="@style/LoginTextInputLayoutStyle"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    app:errorEnabled="false">
                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/totalPiecesProduct"
                        android:layout_gravity="center"
                        android:gravity="center"
                        android:padding="0dp"
                        android:textSize="13sp"
                        style="@style/TextInputEditTextStyle"/>
                </com.google.android.material.textfield.TextInputLayout>
the keys are:
app:errorEnabled="false" in TextInputLayout
`android:padding="0dp"` in `TextInputEditText`
before:

after

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