Question

How to change the color of the text upon highlighting it? Here is what I have tried:

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">

Normal state:

enter image description here

Highlight state:

enter image description here

What I want upon highlighting the text:

enter image description here

Was it helpful?

Solution

I do not think this is supported. From what I see in source code, there is no separate attribute for highlighted text, only for highlighted background. Text is drawn with text color states only, highlighted or not.

Also, android:state_selected="true" represents ColorState of aView, not of text inside it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top