androidpaddingandroid-textinputlayout

Removing TextInputLayout extra top padding


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

enter image description here

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?


Solution

  • 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