Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从com.google.android.material.textfield.TextInputLayout中删除背景错误红色_Android_Material Design_Android Textinputlayout_Material Components Android - Fatal编程技术网

如何从com.google.android.material.textfield.TextInputLayout中删除背景错误红色

如何从com.google.android.material.textfield.TextInputLayout中删除背景错误红色,android,material-design,android-textinputlayout,material-components-android,Android,Material Design,Android Textinputlayout,Material Components Android,我不擅长使用材料设计。我有自定义背景,但设置错误消息时,我的textinputtext背景为红色;它在触摸时显示在textinputtext中 如何从textinputtext中删除此红色错误背景 这是我的设计xml <com.google.android.material.textfield.TextInputLayout android:id="@+id/userIdLayout" android:layout_wid

我不擅长使用材料设计。我有自定义背景,但设置错误消息时,我的
textinputtext
背景为红色;它在触摸时显示在
textinputtext

如何从
textinputtext
中删除此红色错误背景

这是我的设计xml

<com.google.android.material.textfield.TextInputLayout
            android:id="@+id/userIdLayout"
            android:layout_width="wrap_content"
            app:boxBackgroundMode="none"
            app:boxBackgroundColor="@android:color/transparent"
            app:hintEnabled="false"
            app:errorEnabled="true"
            app:errorTextColor="@color/red"
            android:layout_height="wrap_content">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/userId"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:backgroundTintMode="@null"
                android:background="@drawable/border_blue_fill_white_rectangle"
                android:drawableStart="@drawable/ic_account"
                android:drawablePadding="8dp"
                android:ems="14"
                android:fontFamily="@font/carrois_gothic"
                android:hint="@string/userId"
                android:longClickable="false"
                android:inputType="text"
                android:maxLines="1"
                android:paddingStart="16dp"
                android:paddingTop="12dp"
                android:paddingEnd="24dp"
                android:paddingBottom="12dp"
                android:text="@={LoginViewModel.userId}"
                android:textSize="16sp"
                android:textColor="@color/colorPrimaryDark"
                android:importantForAutofill="no" />

        </com.google.android.material.textfield.TextInputLayout>
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="colorError">@android:color/transparent</item>
    <item name="windowActionBar">false</item>
    <item name="editTextBackground">@color/white</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:actionMenuTextAppearance">@style/AppTheme.PopupOverlay</item>
</style>

这是我的风格。xml

<com.google.android.material.textfield.TextInputLayout
            android:id="@+id/userIdLayout"
            android:layout_width="wrap_content"
            app:boxBackgroundMode="none"
            app:boxBackgroundColor="@android:color/transparent"
            app:hintEnabled="false"
            app:errorEnabled="true"
            app:errorTextColor="@color/red"
            android:layout_height="wrap_content">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/userId"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:backgroundTintMode="@null"
                android:background="@drawable/border_blue_fill_white_rectangle"
                android:drawableStart="@drawable/ic_account"
                android:drawablePadding="8dp"
                android:ems="14"
                android:fontFamily="@font/carrois_gothic"
                android:hint="@string/userId"
                android:longClickable="false"
                android:inputType="text"
                android:maxLines="1"
                android:paddingStart="16dp"
                android:paddingTop="12dp"
                android:paddingEnd="24dp"
                android:paddingBottom="12dp"
                android:text="@={LoginViewModel.userId}"
                android:textSize="16sp"
                android:textColor="@color/colorPrimaryDark"
                android:importantForAutofill="no" />

        </com.google.android.material.textfield.TextInputLayout>
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="colorError">@android:color/transparent</item>
    <item name="windowActionBar">false</item>
    <item name="editTextBackground">@color/white</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:actionMenuTextAppearance">@style/AppTheme.PopupOverlay</item>
</style>

@颜色/原色
@颜色/原色暗
@颜色/颜色重音
@android:彩色/透明
假的
@颜色/白色
@空的
@style/AppTheme.PopupOverlay
这是我的定制背景

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle"
android:color="@android:color/transparent" >
<solid android:color="@android:color/white" />
<corners android:radius="32dp" />
    <stroke
        android:width="2px"
        android:color="@color/colorPrimaryDark" />
</shape>

这是图像


不要在
文本输入文本上使用
android:background
。只需应用样式
小部件.MaterialComponents.TextInputLayout.OutlineBox

<com.google.android.material.textfield.TextInputLayout
            app:boxStrokeColor="@color/..."
            app:boxBackgroundColor="@color/white"
            android:hint="..."
            app:startIconDrawable="@drawable/...."
            app:shapeAppearanceOverlay="@style/corner32"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
            ....>

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/userId"
                android:drawablePadding="8dp"
                android:ems="14"
                android:longClickable="false"
                android:inputType="text"
                android:maxLines="1"
                android:paddingStart="16dp"
                android:paddingTop="12dp"
                android:paddingEnd="24dp"
                android:paddingBottom="12dp"
                android:text="User id"
                android:textSize="16sp"
                android:textColor="@color/colorPrimaryDark"
                android:importantForAutofill="no"
                .... />

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

不要在
文本输入文本上使用
android:background
。只需应用样式
小部件.MaterialComponents.TextInputLayout.OutlineBox

<com.google.android.material.textfield.TextInputLayout
            app:boxStrokeColor="@color/..."
            app:boxBackgroundColor="@color/white"
            android:hint="..."
            app:startIconDrawable="@drawable/...."
            app:shapeAppearanceOverlay="@style/corner32"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
            ....>

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/userId"
                android:drawablePadding="8dp"
                android:ems="14"
                android:longClickable="false"
                android:inputType="text"
                android:maxLines="1"
                android:paddingStart="16dp"
                android:paddingTop="12dp"
                android:paddingEnd="24dp"
                android:paddingBottom="12dp"
                android:text="User id"
                android:textSize="16sp"
                android:textColor="@color/colorPrimaryDark"
                android:importantForAutofill="no"
                .... />

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

不要在文本输入文本上使用android:background然后我如何使用自定义背景@GabrieleMariotti您使用的只是一个带有圆角和笔划的形状。它可以提供没有自定义背景的标准属性md。不要在文本InputItemXT上使用android:background。那么我如何使用自定义背景@GabrieleMariotti?你只是使用了一个带有圆角和笔划的形状。它可以提供标准属性,而无需自定义背景。