光标颜色和文字颜色相同
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"这样就实现了光标样式的自定义。 注意:该属性中不能直接写颜色,因为没有宽度的话,光标是无法显示的。
新闻热点
疑难解答