如图:

步骤一
在/res/drawable
文件夹下创建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>
步骤二
布局文件中设置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" />
网友评论