Tuesday, August 18, 2015

How to change EditText cursor color in Android

activity_main.xml

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rl"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp"
    tools:context=".MainActivity"
    android:background="#ced4cb"
    >
    <!--
        android:textCursorDrawable="@null"
        android:textColor

            Set the android:textCursorDrawable attribute value to @null,
            then EditText widget will display text color as cursor color
    -->
    <EditText
        android:id="@+id/et"
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:hint="Input your country"
        android:padding="10dp"
        android:textCursorDrawable="@null"
        />
    <EditText
        android:id="@+id/et_city"
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:hint="Input your City"
        android:padding="10dp"
        android:layout_below="@+id/et"
        android:textCursorDrawable="@null"
        android:textColor="#ff0004"
        />
</RelativeLayout>
More android examples