如何用EditText完全填充TextInputLayout?

How to fill TextInputLayout with EditText fully?

我有 TextInputLayout 中的 EditText。 我想要实现的是 EditText 完全位于 TextInputLayout 内,以摆脱编辑字段顶部的空白 space。

布局如下:

 <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/login_edit_style"
        android:hint=" "> <!--android:hint=" "> if (TextUtils.isEmpty(mHint)) evaluates to false, and the EditText retains its hint.-->


        <EditText
            android:id="@+id/login"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/transparent"
            android:drawableLeft="@drawable/ic_person"
            android:fontFamily="@font/montserrat"
            android:hint="Email"
            android:inputType="textEmailAddress"
            android:lineSpacingMultiplier="1.17"
            android:paddingLeft="@dimen/field_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:textColor="#4A4A4A"
            android:textColorHint="@color/colorPrimaryDark"
            android:textCursorDrawable="@drawable/cursor_colour"
            android:textSize="12sp" />

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

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/login_edit_style"
        android:hint=" "> <!--if (TextUtils.isEmpty(mHint)) evaluates to false, and the EditText retains its hint.-->

        <EditText
            android:id="@+id/password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:drawableLeft="@drawable/ic_locker"
            android:drawableRight="@drawable/ic_show_pass"
            android:ems="10"
            android:hint="Password"
            android:inputType="textPassword"
            android:lineSpacingMultiplier="1.17"
            android:paddingLeft="@dimen/field_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:textColor="#4A4A4A"
            android:textColorHint="@color/colorPrimaryDark"
            android:textCursorDrawable="@drawable/cursor_colour"
            android:textSize="12sp" />

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

顶部的space是当用户关注EditText时出现的浮动标签,像这样:

如果您不想要那个浮动标签,请改用 EditText。此外,如果您使用 TextInputLayout,您应该在其中使用 TextInputEditText 而不仅仅是 EditText.