光標顏色和文字顏色相同
android:textCursorDrawable="@null"此時光標顏色與字體顏色相同,寬度為最窄。
實現自己自定義的光標樣式 在drawable文件夾下新建一個樣式xml文件custom_cursor.xml。其中的代碼為:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#00bb9c"/> <size android:width="2dp"/> </shape>EditText設置textCursorDrawable的屬性:
android:textCursorDrawable="@drawable/editcursor"這樣就實現了光標樣式的自定義。 注意:該屬性中不能直接寫顏色,因為沒有寬度的話,光標是無法顯示的。
新聞熱點
疑難解答