5

I am working on dynamic theme apply on Android application concept. I am applying theme color programmatically for all UI. I want to change EditText selection background color programmatically. enter image description here

Any help would be much appreciated. I want to change textselection highlight color.

Samir Bhatt
  • 3,041
  • 2
  • 25
  • 39

4 Answers4

2

Background color as you mentioned in your question is known as HighlightColor for EditText.

Try this,

et.setHighlightColor(ContextCompat.getColor(getContext(), R.color.highlight));
Kuls
  • 2,047
  • 21
  • 39
1

To highlight the selection Use setHighlightColor feature in the code for the EditText. It is not background color. Its HighLightColor.

IN CODE

editTextName.setHighlightColor(ContextCompat.getColor(getContext(), R.color.highlight));
Pravin Pawar
  • 2,559
  • 3
  • 34
  • 40
Tomin B Azhakathu
  • 2,656
  • 1
  • 19
  • 28
1

If you have EditText with name editText use setHighlightColor() method:

editText.setHighlightColor(getResources().getColor(R.color.some_color);
godot
  • 3,422
  • 6
  • 25
  • 42
0

Don't know whether is this you are looking for , but why don't you try:

textView.setBackgroundColor(getResources().getColor(R.color.colorID));