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即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章