我用过这个。
<color name="edt_pressed">#99CBFF</color>
<color name="edt_focused">#CEF7F6</color>
<color name="edt_default">#000000</color>
梯度_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>
活动_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"/>
现在边框工作正常,但在输入文本时,其背景颜色为黑色。
问题是它在焦点时将默认项目的颜色作为背景,因为我没有为每个项目提供任何纯色。所以现在我将其添加到“gradient_edt_focused”中。
<solid android:color="#00000000" />
现在它正在发挥作用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)