Android 修改EdtiText光标颜色

1.新建一个drawable文件cursor_red

<?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="#FF0000" />
</shape>

rectangle:长方形
此处光标以长方形显示,宽度为2dp
使用方式如下

<EditText
                android:id="@+id/edit_amount"
                android:layout_marginLeft="20dp"
                android:layout_width="200dp"
                android:layout_height="match_parent"
                android:background="@null"
                android:textSize="30dp"
                android:gravity="bottom"
                android:textCursorDrawable="@drawable/cursor_red" />

设置属性:android:textCursorDrawable即可

猜你喜欢

转载自blog.csdn.net/llm20143304/article/details/83025869