我可以改变的机器人编辑文本字段中的光标大小?光标、字段、机器人、文本

2023-09-06 01:11:48 作者:冰是睡着的水

我想改变这种闪烁在Android领域的EditText光标的宽度和颜色。这可能吗?

I want to change the width and color of the cursor that blinks in an Android EditText field. Is that possible?

推荐答案

RES /绘制/ cursor_red.xml:

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

在你的EditText:

android:textCursorDrawable="@drawable/cursor_red"

请注意:只有API 12及以上

note: only API 12 and above