tags:

views:

245

answers:

2

I'm not sure that this is possible, perhaps someone can set me straight. I have an EditText View in an android application that has white text on a blue background. When the text is selected (via a long press and the edit dialog), I'd like have the highlight be white and change the text color to be black. Annoyingly though there does not seem to be a way to set the color of the text on highlight. You can set the highlight color using textColorHighlight, but not the text color, so setting a white highlight with white text results in a big white block.

It seems like it should be something trivial you can do declaratively in the xml, but though I've tried many combinations of styles and colors, I've not been able to change the color.

Checking other standard applications it seems that the text color never seems to change so I'm thinking this is something that's not easily done. I'd rather not have to subclass the EditText if at all possible just to something so simple. Am I missing something? Can this be done in the view xml?

A: 

Did you try @android:attr/textColorPrimaryInverse ?

fedj
I've tried all of <EditText android:id="@+id/digits" android:textColorPrimary="@color/my_text_highlight" android:textColorSecondary="@color/my_text_highlight" android:textColorPrimaryInverse="@color/my_text_highlight" android:textColorSecondaryInverse="@color/my_text_highlight" />and a stylestyle="@style/myDisplayAppearance" where all the above were specified as items. Sadly, no luck with any of them.
sgargan
As I said, did you try android:textColor="?android:attr/textColorPrimaryInverse" ?
fedj
Yes I tried the above, it just changes the default text color to textColorPrimaryInverse, which in my case is black. I'm really trying to make it white be default and black only on highlight.When, if ever, are the inverse colors applied? thanks for your help btw.
sgargan
You should take a look to : http://developer.android.com/reference/android/R.attr.html in the text* attributes
fedj
A: 

Hi sgargan,

Were you able to do that? (Changing text color on highlight) I too m looking for such a thing..n no luck so far..

miku
No miku it does not seem like it is possible in the version I'm using (2.2), at least I've not managed to do so and I sunk a fair amount of effort into trying. Hopefully it will be something that gets added soon.
sgargan