material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[TextInputEditText] The highlight color is different from the cursor color

Open almr0 opened this issue 2 years ago • 2 comments

I used all the styling attributes in the theme. (Except for additional attributes).

The theme is night and day. Theme.Material3.Light.NoActionBar and dark respectively

Why can't the selection color be changed? Even colorControlActivated and colorPrimary inside the TextInputEditText style does not save. The first attribute changes only the color of the cursor itself. There is zero information on this on the Internet at all. Screenshot_20220709-194418_VeartMe

almr0 avatar Jul 09 '22 16:07 almr0

I found a solution in the dynamic Material 3 styles code. You need to use android:textColorHighlight attribute to change the color of the text selection. I ask developers to document this attribute in Material3 documentation, because it is very time consuming to find the answer. Especially in Material Components such problems were solved by using accent attribute.

almr0 avatar Jul 10 '22 20:07 almr0

I remember reporting the same issue back in #2452. The maintainers said that they would discuss this, but there has been no updates since.

This is the offending text color in the library, which hard-codes a text color instead of using an attribute.

@drchen Any updates on if text highlighting will be changed to use color attributes?

OxygenCobalt avatar Jul 11 '22 16:07 OxygenCobalt

Hi, I will update the text field documentation to include information about android:textColorHighlight, (programmatically you can also call setHighlightColor on the edit text). We don't currently have plans on introducing a different attr for that

leticiarossi avatar Aug 30 '22 21:08 leticiarossi

Yeah, not surprised you aren't considering it, given that making the text color highlight color rely on attrs will not work <API 23.

OxygenCobalt avatar Aug 30 '22 21:08 OxygenCobalt

That is disappointing to hear that the highlight color will not automatically adjust. This is contrary to how the rest of the theming system behaves.

tipa avatar Oct 26 '22 13:10 tipa

Any updates? We have the same issue

GrigorevKirill avatar Nov 23 '23 15:11 GrigorevKirill