androidxmlmaterial-designandroid-textinputlayoutandroid-textinputedittext

How to change the cursor color in textinputedittext inside textinputlayout


enter image description here

How to change the cursor color of textinputedittext.

I used textcursordrawable but it doesn't work. Thanks in advance


Solution

  • If you want to change only the cursor color, 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="colorControlActivated">@color/...</item>
    </style>
    

    enter image description here

    If you want to change the cursor color but also the box, the label..

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

    enter image description here