Search code examples
androiduser-interfaceandroid-edittextandroid-viewandroid-theme

EditText - Text selection background color change programmatically


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.


Solution

  • 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));