I am having this issue where I am using the Android's Holo theme on a tablet project. However, I have a fragment on screen which has a white background. I am adding an EditText component on this fragment. I've tried to override the theme by setting the background of the Holo.Light theme resources. However, my text cursor (carat) remains white and hence, invisible on screen (I can spot it faintly in the edittext field..).

Does anyone know how I can get EditText to use a darker cursor color? I've tried setting the style of the EditText to "@android:style/Widget.Holo.Light.EditText" with no positive result.

Solution 1

Setting the android:textCursorDrawable attribute to @null should result in the use of android:textColor as the cursor color.

Attribute "textCursorDrawable" is available in API level 12 and higher

Solution 2

In Layout


Then create drawalble xml: color_cursor

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="" >
    <size android:width="3dp" />
    <solid android:color="#FFFFFF"  />

You have a white color cursor on EditText property.

Solution 3

It appears as if all the answers go around the bushes.

In your EditText, use the property:


and add the drawable black_cursor.xml to your resources, as follows:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="" android:shape="rectangle" >
    <size android:width="1dp" />
    <solid android:color="#000000"/>

This is also the way to create more diverse cursors, if you need.

Solution 4

There is a new way to change cursor color in latest Appcompact v21
Just change colorAccent in style like this:

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Set theme colors from>

    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">#088FC9</item>

    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#088FC9</item>

    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#0091BC</item> 

Then apply this style on your app theme or activities.

Update: this way only works on API 21+
Update 2: I'm not sure the minimum android version that it can work.
Tested by android version:

2.3.7 - didn't work
4.4.4 - worked
5.0 - worked
5.1 - worked

Solution 5

I found the answer :)

I've set the Theme's editText style to:

<item name="android:editTextStyle">@style/myEditText</item>

Then I've used the following drawable to set the cursor:


<style name="myEditText" parent="@android:style/Widget.Holo.Light.EditText">
    <item name="android:background">@android:drawable/editbox_background_normal</item>
    <item name="android:textCursorDrawable">@android:drawable/my_cursor_drawable</item>
    <item name="android:height">40sp</item>


android:textCursorDrawable is the key here.

Solution 6

For anyone that needs to set the EditText cursor color dynamically, below you will find two ways to achieve this.

First, create your cursor drawable:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android=""
    android:shape="rectangle" >

    <solid android:color="#ff000000" />

    <size android:width="1dp" />


Set the cursor drawable resource id to the drawable you created (">source)):

try {
    Field f = TextView.class.getDeclaredField("mCursorDrawableRes");
    f.set(yourEditText, R.drawable.cursor);
} catch (Exception ignored) {

To just change the color of the default cursor drawable, you can use the following method:

public static void setCursorDrawableColor(EditText editText, int color) {
    try {
        Field fCursorDrawableRes = 
        int mCursorDrawableRes = fCursorDrawableRes.getInt(editText);
        Field fEditor = TextView.class.getDeclaredField("mEditor");
        Object editor = fEditor.get(editText);
        Class<?> clazz = editor.getClass();
        Field fCursorDrawable = clazz.getDeclaredField("mCursorDrawable");

        Drawable[] drawables = new Drawable[2];
        Resources res = editText.getContext().getResources();
        drawables[0] = res.getDrawable(mCursorDrawableRes);
        drawables[1] = res.getDrawable(mCursorDrawableRes);
        drawables[0].setColorFilter(color, PorterDuff.Mode.SRC_IN);
        drawables[1].setColorFilter(color, PorterDuff.Mode.SRC_IN);
        fCursorDrawable.set(editor, drawables);
    } catch (final Throwable ignored) {

Solution 7

Late to the party,Here's is my answer,

This is for the people who are not looking to change the colorAccent in their parent theme,but wants to change EditText attributes!

This answer demos how to change ......

  1. Bottom line color
  2. Cursor color
  3. Cursor pointer color (I used my custom image).......... of EditText using style applied to the Activity theme.

    android:text="Hey" />


<style name="AppTheme.EditText" parent="@style/Widget.AppCompat.EditText">
    <item name="android:textColor">@color/white</item>
    <item name="android:textColorHint">#8AFFFFFF</item>
    <item name="android:background">@drawable/edit_text_background</item> // background (bottom line at this case)
    <item name="android:textCursorDrawable">@color/white</item>  // Cursor
    <item name="android:textSelectHandle">@drawable/my_white_icon</item> // For pointer normal state and copy text state
    <item name="android:textSelectHandleLeft">@drawable/my_white_icon</item>
    <item name="android:textSelectHandleRight">@drawable/my_white_icon</item>

Now create a drawable(edit_text_background) add a resource xml for the background!You can customize as you want!

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="">

        <shape android:shape="rectangle">

Now as you did set this style in your Activity theme.

Example :

In your Activity you have a theme,set this custom editText theme to that.

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Your Theme data -->
    <item name="editTextStyle">@style/AppTheme.EditText</item> // inculude this

Solution 8

Edittext cursor color you want changes your color.

Then create drawalble xml: color_cursor

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="" >
    <size android:width="3dp" />
    <solid android:color="#FFFFFF"  />

Solution 9

Wow I am real late to this party but it has had activity 17 days ago It would seam we need to consider posting what version of Android we are using for an answer so as of now this answer works with Android 2.1 and above Go to RES/VALUES/STYLES and add the lines of code below and your cursor will be black

    <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <!--<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">-->
    <!-- Customize your theme here. -->
    <item name="colorControlActivated">@color/color_Black</item>
    <!--Sets COLOR for the Cursor in EditText  -->

You will need a this line of code in your RES/COLOR folder

<color name="color_Black">#000000</color>

Why post this late ? It might be nice to consider some form of categories for the many headed monster Android has become!

Solution 10

For me I modified both the AppTheme and a value colors.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorControlNormal">@color/yellow</item>
    <item name="colorAccent">@color/yellow</item>

Here is the colors.xml

<?xml version="1.0" encoding="utf-8"?>
    <color name="yellow">#B7EC2A</color>

I took out the android:textCursorDrawable attribute to @null that I placed inside the editText style. When I tried using this, the colors would not change.

Solution 11

Use this


Solution 12

The only valid answer should be to change the theme of the activity: <item name="colorAccent">#000000</item> You should not use the android:textCursorDrawable to @null because this only concerns the cursor itself but not the pin below the cursor if you want to drag that cursor. The theming solution is the most serious one.

Solution 13

Here @Jared Rummler's programatic setCursorDrawableColor() version adapted to work also on Android 9 Pie.

@SuppressWarnings({"JavaReflectionMemberAccess", "deprecation"})
public static void setCursorDrawableColor(EditText editText, int color) {

    try {
        Field cursorDrawableResField = TextView.class.getDeclaredField("mCursorDrawableRes");
        int cursorDrawableRes = cursorDrawableResField.getInt(editText);
        Field editorField = TextView.class.getDeclaredField("mEditor");
        Object editor = editorField.get(editText);
        Class<?> clazz = editor.getClass();
        Resources res = editText.getContext().getResources();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            Field drawableForCursorField = clazz.getDeclaredField("mDrawableForCursor");
            Drawable drawable = res.getDrawable(cursorDrawableRes);
            drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
            drawableForCursorField.set(editor, drawable);
        } else {
            Field cursorDrawableField = clazz.getDeclaredField("mCursorDrawable");
            Drawable[] drawables = new Drawable[2];
            drawables[0] = res.getDrawable(cursorDrawableRes);
            drawables[1] = res.getDrawable(cursorDrawableRes);
            drawables[0].setColorFilter(color, PorterDuff.Mode.SRC_IN);
            drawables[1].setColorFilter(color, PorterDuff.Mode.SRC_IN);
            cursorDrawableField.set(editor, drawables);
    } catch (Throwable t) {
        Log.w(TAG, t);

Solution 14


<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimary</item>
    <item name="colorAccent">@color/colorAccent</item> -- change this one

Go to styles.xml and change the color accent and this will influence the cursor from the edittext box

Solution 15

that's called colorAccent in Android.

go to res -> values -> styles.xml add

<item name="colorAccent">#FFFFFF</item>

if not exists.

Solution 16

We can do it in meterial theme as following:

<style name="Theme.App" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="android:colorControlNormal">#ff0000</item>
    <item name="android:colorControlActivated">#ff0000</item>
    <item name="android:colorControlHighlight">#ff0000</item>

And if you want to change checkbox and radio colors too, add the following line:

<item name="colorAccent">#ff0000</item>

I've tested in Android API 21+

Solution 17



In xml file set color code of edittext background color

Solution 18

After a lot of time spent trying all these technique in a Dialog, I finally had this idea : attach the theme to the Dialog itself and not to the TextInputLayout.

<style name="AppTheme_Dialog" parent="Theme.AppCompat.Dialog">

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorWhite</item>
    <item name="colorAccent">@color/colorPrimary</item>


inside onCreate :

public class myDialog extends Dialog {

private Activity activity;
private someVars;

public PopupFeedBack(Activity activity){

cheers :)

Solution 19

Pay attention to your colorAccent in your current Activity/fragment/Dialog, defined in Styles... ;) cursor color is related to it.

Solution 20

Another simple solution would be to go to res>values>colors.xml in your project folder and edit the value of the color accent to the color you prefer

<color name="colorAccent">#000000</color>

The code above changes your cursor to black.

Solution 21

Its even easier than that.

<style name="MyTextStyle">
    <item name="android:textCursorDrawable">#000000</item>

This works in ICS and beyond. I haven't tested it in other versions.

Solution 22

are you want specific color you must use AppCompatEditText then backround set null

works for me


See this gist

Solution 23

In API 21 and above:


// In colors.xml
<style name="CursorColor">
    <item name="colorPrimary">@color/black</item>

Solution 24

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">#36f0ff</item>
    <item name="colorPrimaryDark">#007781</item>
    <item name="colorAccent">#000</item>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

change t he color of colorAccent in styles.xm, that's it simple

Solution 25

If using style and implement


replace its value other that color/white.

Solution 26

you can use code below in layout


Solution 27

<style name="CustomTheme" parent="AppTheme">
    <item name="colorAccent">@color/yourColor</item>

Add this in styles and then in the Edittext set the theme as follows:


And thats it!