如何设置的EditText边框颜色 [英] How to set border color for EditText
本文介绍了如何设置的EditText边框颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用这个。
<color name="edt_pressed">#99CBFF</color>
<color name="edt_focused">#CEF7F6</color>
<color name="edt_default">#000000</color>
gradient_edt_focused
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="1dip" android:color="@color/edt_focused" />
</shape>
edt_border.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@layout/gradient_edt_pressed"/>
<item android:state_focused="true" android:drawable="@layout/gradient_edt_focused"/>
<item android:drawable="@layout/gradient_edt_default"/>
</selector>
activity_main.xml中
<EditText
android:id="@+id/uname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:background="@layout/textview_border"/>
现在的边界正在工作正常,但打字时的文字,有黑色的背景色。
Now the border is working fine but while typing text, that has the background color of black.
推荐答案
问题是它正在为背景的默认项的颜色,而聚焦状态,因为我没有给任何纯色每个。所以现在我加入这gradient_edt_focused。
The issue is it is taking the color of the default item as background while onfocus as I did not gave any solid color for each. So now i added this in "gradient_edt_focused".
<solid android:color="#00000000" />
现在它工作。
这篇关于如何设置的EditText边框颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文