Search code examples
androidandroid-themeandroid-stylesmaterial-components-androidandroid-textinputlayout

Android TextInputLayout and TextInputEditText cursor color problem


enter image description hereProblem

I have this problem, after the xxx is the cursor in violet, I want to know the name of that drop cursor, I want to change the color to match my theme. I read many forums and documentation, the only I find was cursorDrawable, but is not that. Please help me with the correct name to search or the solution. Thanks PD: The violet color of that THING is not in my styles or colors.


Solution

  • The color is based on colorPrimary.

    If you want to override the colorPrimary you can use:

      <com.google.android.material.textfield.TextInputLayout                
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:theme="@style/ThemeOverlay.AppTheme.TextInputEditText.Outlined"
        ....>
    

    with:

    <style name="ThemeOverlay.AppTheme.TextInputEditText.Outlined" parent="">
        <item name="colorPrimary">@color/...</item>
    </style>
    

    enter image description here

    If you want to override only the cursor you can use:

    <style name="ThemeOverlay.AppTheme.TextInputEditText.Outlined" parent="">
        <item name="colorControlActivated">@color/...</item>
    </style>
    

    enter image description here

    enter image description here