android - 高亮显示的 EditText 文本颜色

标签 android xml android-edittext android-selector

如何在突出显示文本时更改文本颜色?这是我尝试过的:

edittext_text_color.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_selected="true" android:color="#FFFFFF"/>
    <item android:state_selected="false" android:color="@color/custom_blue"/>

</selector>

some_layout.xml:

<org.holoeverywhere.widget.EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:layout_margin="5dp"
    android:background="@android:drawable/editbox_background_normal"
    android:ems="10"
    android:gravity="right"
    android:inputType="textPersonName"
    android:textColor="@drawable/edittext_text_color"
    android:textCursorDrawable="@null">

正常状态:

enter image description here

突出显示状态:

enter image description here

突出显示文本时我想要什么:

enter image description here

最佳答案

我认为这不受支持。从我在source code中看到的,突出显示的文本没有单独的属性,仅适用于突出显示的背景。仅使用文本颜色状态绘制文本,无论是否突出显示。

此外,android:state_selected="true" 表示 ViewColorState,而不是其中的文本。

关于android - 高亮显示的 EditText 文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17938034/

相关文章:

java - Intent.putExtra 传递空值

java - 获取不同类型的 JSON 响应 Retrofit

c - 在 C 中使用 xmlReadFile 时出现警告/错误

sql-server - Xpath不正确地转换Char(13)

Android EditText 不显示键盘

android - 具有单个可编辑行的 TextView

java - 从 firebase 检索并显示值

java - 菜单打开时覆盖后退按钮

android - 如何在 kotlin 的 xml 标签中自动添加相同的 xml 代码?

android - Android中如何知道EditText发生了删除操作?