How to change EditText cursor height?

Viewed 13969

I want to change the EditText cursor height, does anyone know how?

3 Answers

Paddings can be used to control cursor height

cursor.xml

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

cursor_with_padding.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:bottom="7dp"
        android:drawable="@drawable/cursor"
        android:top="8dp" />
</layer-list>

layout

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