Search code examples
androidxmlandroid-edittextmaterial-designandroid-textinputlayout

Android TextInputLayout remove extra space below edittext


I'm using TextInputLayout.FilledBox.Dense as style for my TextInputLayout and then I disable the hint by adding hintEnabled=false but then It adds extra line at the bottom of EditText

Code snippet

<android.support.design.widget.TextInputLayout
            android:id="@+id/name_text_input"
          style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.Dense"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:hintAnimationEnabled="false"
            app:hintEnabled="false">

            <EditText
                android:id="@+id/login_tab_userid3"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:imeOptions="actionNext"
                android:inputType="textPersonName" />

        </android.support.design.widget.TextInputLayout>

Screenshot

Screenshot


Solution

  • You can remove the line below the your EditText from this android:background="@null" and then creating the View below your EditText for creating the line below the EditText

                <EditText
                    android:layout_width="match_parent"
                    android:background="@null"
                    android:layout_height="wrap_content" />
    
                <View
                    android:layout_width="match_parent"
                    android:background="@android:color/white"
                    android:layout_height="0.5dp"/>