1

I use selector for styling EditTexts. I want to get rid of orange color, when I doubleTap on my EditText. I use this:

states.addState(new int[] {R.attr.textColorHighlight}, getResources().getDrawable(R.color.transparent));

But it doesn't make any difference! Does any body know why? and interestingly this part of the code works well:

states.addState(new int[] {R.attr.state_focused}, getResources().getDrawable(R.color.transparent));

But I don't want to change the state, when focuced!

Maria
  • 89
  • 1
  • 7
  • I think the color is dependent on your OEM rom. – Mgamerz Feb 08 '13 at 16:00
  • u mean there is no way to change it programmatically? – Maria Feb 08 '13 at 16:02
  • 1
    create your custom style for your EditText and make it looks like as you want. – hardartcore Feb 08 '13 at 16:05
  • @Android-Developer: But I thought I've done that with states.addState ... – Maria Feb 08 '13 at 16:07
  • you wan't to change the color when your activity shows up? is that what you want and don't change it's state when user select it? – hardartcore Feb 08 '13 at 16:10
  • I want to remove the orange color wenn I highlight the text in edittext, or what do you mean? – Maria Feb 08 '13 at 16:12
  • What orange color are you referring to? If it's the orange color around the text boxes, a) that's android 2.3, and it's part of the text view drawables b) I believe `R.attr.textColorHighlight` is the color for the *selection*. – dmon Feb 08 '13 at 16:14
  • It is Android 2.3. I'm talking about the text in EditText and when I highlight the text, the backgroundColor of the text goes orange, not the edittext itself actually. :-( – Maria Feb 08 '13 at 16:17
  • He's talking about the highlight color when you're selecting text like when you long click on text in the browser and move the handles. Same as the one in the edittext. – Mgamerz Feb 08 '13 at 16:44

1 Answers1

1

This is not that easy (programmatically). You could try to achieve this by using StateListDrawable. You can use a StateListDrawable as the background of your EditText in your theme so you can handle the different states.

If found a very interesting sample which maybe helps you out. Sorry but I didn't try it myself: Apply StateListDrawable programmatically

Community
  • 1
  • 1
MUG4N
  • 19,377
  • 11
  • 56
  • 83