Changing TextInputEditText's select mode color

47 Views Asked by At

enter image description here

I am using TextInputLayout and TextInputEditText. I cant find a way to change this purple color. I searched about it too but i cant find so much. How can i change it?

1

There are 1 best solutions below

2
Narmo On

You need to add a little bit of styling to your app.

In styles.xml (or what is the name of your app's main theme file) you need to set textInputStyle for your app's theme:

<style name="AppTheme" parent="Theme.Material3.DayNight.NoActionBar">
    ...
    <item name="textInputStyle">@style/Widget.App.TextInputLayout.OutlinedBox</item>
    ...
</style>

Then you need to create a style for your TextInputLayout (in my case the parent style is OutlinedBox but you can choose any other style you want) and set android:textColorHighlight and android:colorControlActivated to your desired color. textColorHighlight sets the background color of selected text and colorControlActivated sets the color of two "holders" around the text:

<style name="Widget.App.TextInputLayout.OutlinedBox" parent="Widget.Material3.TextInputLayout.OutlinedBox">
    <item name="android:textColorHighlight">#ff0000</item>
    <item name="android:colorControlActivated">#00ff00</item>
</style>

And after these manipulations you'll see the following result:

Themed selection controls