如何在 android studio 中为 android TextInputLayout 移除方框并仅添加下划线

How to remove box and add only underline like the old style for android TextInputLayout in android studio

我想在不将样式设置为旧式的情况下创建以下内容,因为它会产生其他问题,例如 AutoCompleteTextView。

style="@style/Widget.Design.TextInputLayout"

您可以在 FilledBox 样式的 TextInputLayout 上使用 app:boxBackgroundColor="@android:color/transparent" 来只有下划线而没有方框。

像这样:

 <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/outlinedTextField"
        style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:boxBackgroundColor="@android:color/transparent"
        android:hint="label">

        <com.google.android.material.textfield.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            />

    </com.google.android.material.textfield.TextInputLayout>

如果您想同时删除方框和下划线,请使用:app:boxBackgroundMode="none"