如圖:

步驟一
在/res/drawable文件夾下創(chuàng)建edit_cursor_color.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="#F00" />
</shape>
步驟二
布局文件中設(shè)置EditText的textCursorDrawable屬性為edit_cursor_color:
<EditText
android:id="@+id/et_input"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="2dp"
android:background="@drawable/edit_text_bg"
android:inputType="text"
android:labelFor="@id/et_input"
android:textCursorDrawable="@drawable/edit_cursor_color"
android:textSize="18sp"
tools:ignore="Autofill" />