Android 样式编辑器文本下划线颜色
我正在创建一个应用程序,它有两个edittext,当edittext有焦点或没有焦点时,会改变颜色。当视图具有焦点时,颜色应为蓝色,正常情况下应为白色,如下所示: 我尝试过创建两个9补丁,并根据这个xml设置背景,但似乎不起作用。有人能告诉我如何才能做到这一点吗 Xml选择器:Android 样式编辑器文本下划线颜色,android,android-edittext,android-xml,android-background,Android,Android Edittext,Android Xml,Android Background,我正在创建一个应用程序,它有两个edittext,当edittext有焦点或没有焦点时,会改变颜色。当视图具有焦点时,颜色应为蓝色,正常情况下应为白色,如下所示: 我尝试过创建两个9补丁,并根据这个xml设置背景,但似乎不起作用。有人能告诉我如何才能做到这一点吗 Xml选择器: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enable
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:state_focused="true"
android:drawable="@drawable/spelling_blue" />
<item android:state_window_focused="false" android:state_enabled="true"
android:drawable="@drawable/spelling_white" />
<item android:drawable="@drawable/spelling_white" />
</selector>
谢谢我认为你不需要使用
android:state\u window\u focused
试试这个:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/spelling_blue" /> <!-- pressed -->
<item
android:state_focused="true"
android:drawable="@drawable/spelling_blue" /> <!-- focused -->
<item
android:drawable="@drawable/spelling_white" /> <!-- default -->
</selector>
我认为您不需要使用
android:state\u window\u focused
试试这个:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/spelling_blue" /> <!-- pressed -->
<item
android:state_focused="true"
android:drawable="@drawable/spelling_blue" /> <!-- focused -->
<item
android:drawable="@drawable/spelling_white" /> <!-- default -->
</selector>
试试这个,希望它能帮助你。你有什么资源?你能用蓝色和白色拼写吗?试试这个,希望它能帮助你。你有什么资源?你能显示拼写为蓝色和白色吗?试试看