TextInputLayout 删除不需要的 space

TextInputLayout remove unwanted space

我想要没有任何边框和框的 TextInputLayout,所以我使用下面的代码

<com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/app_name"
        app:boxBackgroundMode="none"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <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"

到 TextInputLayout 然后大小是一个自动拉伸并且看起来很奇怪如果你找到任何关于这个的解决方案请帮助我。

这是我输出的截图

是因为app:boxBackgroundMode="none"

尝试使用以下代码来实现您的设计

<com.google.android.material.textfield.TextInputLayout
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:backgroundTint="@color/white"
    app:boxStrokeColor="@color/white"
    app:boxBackgroundColor="@color/white"
    android:background="@color/white"
    android:hint="@string/app_name">

    <EditText
        android:background="@color/white"
        android:backgroundTint="@color/white"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

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