How can I change the color of the EditText selection and pointer?

2

I want to change the color of the seleção of the text in a EditText and also change the color of the bolinha (the name is pointer if I am not mistaken) by java.

It has to be equal to the image that follows only with another color.

    
asked by anonymous 14.10.2017 / 23:10

2 answers

3

I think this can not be changed, dynamically (after EditText was created), via java.

Via XML, create a style:

<style name="SelectionColor">
    <item name="colorControlActivated">#00ff00</item>
    <item name="android:textColorHighlight">#00ff00</item>
</style>

apply it to EditText using

android:theme="@style/SelectionColor"

Notes:

  • The example uses the green color.
  • Cursor color will also be changed.
15.10.2017 / 00:03
1

You can change these things in the values / colors.xml file

<resources>
    <color name="primary">#3F51B5</color>
    <color name="primary_dark">#303F9F</color>
    <color name="primary_light">#C5CAE9</color>
    <color name="accent">#00BCD4</color>
    <color name="primary_text">#212121</color>
    <color name="secondary_text">#727272</color>
    <color name="icons">#FFFFFF</color>
    <color name="divider">#B6B6B6</color>
</resources>

More information:
link link

You can create style:

<style name="green">
        <item name="main_background">@drawable/background_green</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="button_light">@color/button_light</item>
</style>

And set yourself in the code:

activity.setTheme(R.style.green);

More information:
link

    
14.10.2017 / 23:15