Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText - Text selection background color change programmatically [duplicate]

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.

like image 763
Samir Bhatt Avatar asked Feb 05 '18 05:02

Samir Bhatt


2 Answers

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

Try this,

et.setHighlightColor(ContextCompat.getColor(getContext(), R.color.highlight));
like image 157
Kuls Avatar answered Oct 15 '22 10:10

Kuls


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));
like image 1
Tomin B Azhakathu Avatar answered Oct 15 '22 10:10

Tomin B Azhakathu