TextInputLayout将EditText颜色更改为红色

时间:2016-03-09 12:21:15

标签: android colors android-edittext android-textinputlayout

我遇到过这个奇怪的问题,EditText字段会在Red的开头将颜色更改为Activity,就像它们有SetError更改一样。此外,这不会每次都发生,只有在某些情况下才会出现。我该如何解决这个错误?任何帮助表示赞赏。 请参考图片了解更多。 这是代码

 <android.support.design.widget.TextInputLayout
                    android:id="@+id/input_name"
                    style="@style/my_style_textInput"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="8dp">

                    <EditText
                        android:id="@+id/edt_name"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="Name:"
                        android:inputType="textPersonName"
                        android:singleLine="true"
                        android:textSize="@dimen/subHeading" />
                </android.support.design.widget.TextInputLayout>

这是风格:

<style name="my_style_textInput" parent="@style/TextAppearance.AppCompat">
    //hint color And Label Color in False State
    <!--<item name="android:textColorHint">@color/item_color</item>-->
    <!--<item name="android:textColor">@color/colorPrimary</item>-->
    <item name="android:textSize">@dimen/caption</item>
    //Label color in True State And Bar Color False And True State
    <item name="colorAccent">@color/colorPrimary</item>
    <item name="colorControlNormal">@color/colorPrimary</item>
    <item name="colorControlActivated">@color/colorPrimaryAccent</item>
</style>

请注意,colorPrimary,colorAccent和item_color都不是红色的。谢谢。 CHECK IMAGE HERE

1 个答案:

答案 0 :(得分:0)

您可以使用此代码自定义颜色。

在布局上应用android:background =“@ drawable / edittext_bg”

static void mapDestroy(PyObject* capsule);

在drawable之后创建文件edittext_bg.xml并将此代码放入其中。

static

希望它对你有所帮助。