How to change the color of Edittext’s bright cursor?

Asked

Viewed 1,064 times

1

EditText com o cursor rosa

I’d like to know which attribute name changes that color bar,.

1 answer

4

The Edittext has an attribute that defines the drawable to be used for the cursor.

Create the drawable:

my_cursor.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <size android:width="1dp" />
    <solid android:color="#FF0000"  />
</shape>

size android:width defines the thickness.
solid android:color sets the color.

Attribute this drawable to the attribute android:textCursorDrawable:

<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textCursorDrawable="@drawable/my_cursor"/>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.