单击时如何更改文本输入下划线和文本的颜色? [英] How to change color of text input underline and text when clicked?

查看:42
本文介绍了单击时如何更改文本输入下划线和文本的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新

即使在使用 minSdkVersion 21 时,如果我使用 colorControl,它会更改下划线的颜色,但不会更改文本电子邮件"的颜色.知道如何更改文本电子邮件"的颜色吗?

Even when using minSdkVersion 21, if I use colorControl, it changes the color of the underline but not of the text "Email". Any idea how to change the color of the text "Email"?

这是我的应用:

目前,当我点击电子邮件字段时,下划线和文本电子邮件"是绿松石色.我知道如何在未单击时更改下划线的颜色,但是如何在聚焦/单击时更改下划线的颜色?

Currently, when I click into the email field, the underline and the text "Email" is the turquoise color. I know how to change the color of the underline when it is not clicked, but how do I change the color of the underline when it is focussed / clicked on?

我的 minSdkVersion 是 15,所以 colorControl 不起作用,backgroundTint 也没有完成工作.有没有办法用版本 15 及更高版本来完成我想要的?

My minSdkVersion is 15, so colorControl does not work and backgroundTint does not get the job done either. Is there a way to accomplish what I want with version 15 and up?

另外,我使用 <AutoCompleteTextView> 而不是 <EditText> 作为电子邮件地址字段(它实际上是 android studio 在创建登录活动").

Also, I am using <AutoCompleteTextView> and not <EditText> for the email address field (it was actually what android studio uses by default when creating a "Login Activity").

推荐答案

只需添加app:backgroundTint="@color/your_color"在 XML 格式的 AppCompatEditText 中.

Just add app:backgroundTint="@color/your_color" in your AppCompatEditText in XML.

编辑

好的,你需要在styles.xml中添加样式

Alright, you need to add style in styles.xml