如何去除OutlinedBox TextinputLayput的浮动标签的阴影

How to remove shadow from OutlinedBox TextinputLayput's floating label

你可以看到浮动标签的背景不清晰(白色)它有一些shadow.I尝试了很多东西但没有用。

  <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/textInputLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="12dp"
        android:layout_marginStart="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginTop="8dp"
        android:layout_gravity="center"
        app:hintTextColor="@android:color/black"
        app:boxBackgroundColor="@android:color/white"
        app:boxStrokeColor="@color/text_input_box_stroke"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_margin="8dp"
        app:layout_constraintTop_toTopOf="parent"
        android:hint="Filled box(default)">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/editText"
            android:layout_width="match_parent"
            tools:text="@tools:sample/cities"
            android:layout_height="wrap_content" />

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

撞色

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="#0D000000" android:state_focused="true"/>
    <item android:color="#0D000000" android:state_hovered="true"/>
    <item android:color="#0D000000"/>
</selector>

试试这个:

<com.google.android.material.textfield.TextInputLayout
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="username"
                app:boxCornerRadiusBottomStart="5dp"
                app:boxCornerRadiusBottomEnd="5dp"
                app:boxCornerRadiusTopStart="5dp"
                app:boxCornerRadiusTopEnd="5dp"
                app:boxStrokeColor="@color/edittext_box_stroke_color"
                app:errorTextColor="#F81616"
                app:hintTextColor="#0AB939"
                app:endIconMode="clear_text"
                app:endIconTint="#A9A9A9"
                android:textColorHint="#FFcfcfcf"
                android:layout_marginTop="10dp"
                android:layout_marginStart="24dp"
                android:layout_marginEnd="24dp"
                android:layout_marginBottom="10dp">
                <com.google.android.material.textfield.TextInputEditText
                    android:drawableStart="@drawable/user_20"
                    android:drawableTint="@color/edittext_icon_color"
                    android:drawablePadding="8dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@={viewModel.userName}"
                    android:imeOptions="actionNext"
                    android:inputType="text"
                    android:textColor="#3d3d3d"/>

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

这里是 edittext_box_stroke_color.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:color="#cfcfcf"/>
    <item android:state_focused="false" android:color="#fafafa"/>
</selector>