Koen
Koen

Reputation: 1017

How to change highlighted EditText color in Android?

I am totally new to Android and ran into the following: while using the Material Light Theme my EditText turns a shade of pink upon selection.

I searched around how to change it and found the following telling me to change the android:textColorHighlight to my preferred color: How to set color of selection in EditText in my custom theme? (android)

Sadly this doesn't seem to work for me.

This is my styles.xml:

<!-- res/values/styles.xml -->
<resources>
    <!- theme inherits from the material theme -->
    <style name="AppTheme" parent="android:Theme.Material.Light">
        <!-- Customize your theme here. -->
        <item name="android:colorPrimary">@color/colorPrimary</item>
        <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="android:colorAccent">@color/colorAccent</item>
        <item name="android:textColorPrimary">@color/lightText</item>
        <item name="android:navigationBarColor">@color/navigationBarColor</item>
        <item name="android:textColorHighlight">@color/textColorHighlight</item>
        <!-- theme customizations -->
    </style>
</resources>

Any pointers as to what I'm doing wrong?

Thanks!

Upvotes: 1

Views: 5128

Answers (2)

lin charles
lin charles

Reputation: 1

Go to the settings:

enter image description here

And here's the result:

enter image description here

Upvotes: 0

Koen
Koen

Reputation: 1017

Found it:

EditText uses the themecolor defined as: android:colorAccent

So:

<item name="android:colorAccent">@color/colorAccent</item>

Hope this helps anyone in the future

Upvotes: 9

Related Questions