本文介绍了文本属性下方的 EditText 下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更改编辑文本下方的蓝色,我不知道它是什么属性.
I would like to change the blue colour below the edit text, i don't know what property it is.
我尝试为它使用不同的背景颜色,但没有用.
I tried using a different background colour for it but it didn't work.
我在下面附上了一张图片:
I've attached an image below:
推荐答案
以编程方式设置 EditText 的下划线颜色实际上相当容易(只需一行代码).
It's actually fairly easy to set the underline color of an EditText programmatically (just one line of code).
设置颜色:
editText.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
去除颜色:
editText.getBackground().clearColorFilter();
注意:当EditText有焦点时,你设置的颜色不会生效,而是有焦点颜色.
Note: when the EditText has focus on, the color you set won't take effect, instead, it has a focus color.
API 参考:
这篇关于文本属性下方的 EditText 下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!