更改Android中提示EditText的颜色

3

在这里,我想要的提示颜色是蓝色,如图1所示。但是当我点击它时,它变成了粉色,如图2所示。我该如何将其改回蓝色?我尝试更改hintColor,但没有什么用。

<EditText
                android:id="@+id/password"
                android:backgroundTint="@android:color/holo_blue_dark"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/prompt_password"
                android:textColorHint="@android:color/holo_blue_dark"
                android:imeActionId="@+id/login"
                android:imeActionLabel="@string/action_sign_in_short"
                android:imeOptions="actionUnspecified"
                android:inputType="textPassword"
                android:maxLines="1"
                android:singleLine="true" />`

照片1

照片2


可能是重复的问题,参考这个链接如何改变TextInputLayout的浮动标签颜色 - Tamás Kozmér
3个回答

2
想要在评论后显示答案,只需要将此代码添加到style.xml文件中即可。非常感谢。
<item name="colorAccent">@android:color/holo_blue_dark</item>

0

您可以尝试使用直接的颜色代码,例如:

android:textColorHint="#4C33FF"

0
尝试使用TextInputLayout
<android.support.design.widget.TextInputLayout
android:textColorHint="#F7B7C2"
android:layout_width="match_parent"
android:layout_height="match_parent">

<EditText
    android:id="@+id/myid"
    android:textColor="@android:color/black"
    android:hint="something"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</android.support.design.widget.TextInputLayout>  

更新:

styles.xml文件中更改您的Apptheme中的"colorAccent"为您需要的颜色。


已经尝试过了,但似乎不起作用。它似乎只在单词在行上而不是在顶部时受影响(当我点击该行时)。 - Raidline
我的猜测是你的"colorAccent"是粉色,试着先把它改成蓝色或其他颜色,然后告诉我。 - Mounir Elfassi
这段代码有问题,我会将其注释掉: <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:textColorHint="@android:color/holo_blue_dark" android:colorAccent = "@android:color/holo_blue_dark" > - Raidline
不,我的意思是在你的styles.xml文件中的Apptheme中的"colorAccent"。 - Mounir Elfassi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接