Setting the android:textCursorDrawable attribute to @null should result in the use ofandroid:textColor as the cursor color.
这个问题主要出现在当在Android Manifest文件中设置android:minSdkVersion或android:targetSdkVersion为13或更高的数值后,原因是因为系统默认的主题所致,所以要进行特别的定义。
通过以下方法来解决:
android:textCursorDrawable="@null"
这样会使光标的颜色与文字颜色的属性一致
另外也可以用自定义的图片资源,但好像在4.2的系统上无效,设置为null是OK的~
这个属性在低版本的系统上会被忽略,不用担心没有这个属性会造成崩溃。
下面是stackoverflow上的讨论:
http://stackoverflow.com/questions/7238450/set-edittext-cursor-color/9165217#9165217
|
56 |
| |||
本文介绍了如何在Android应用中解决EditText光标颜色不匹配文本颜色的问题,通过将android:textCursorDrawable属性设置为@null,可以使光标颜色与文本颜色保持一致。此方法适用于设置了较高minSdkVersion的应用,并且不会导致低版本系统出现崩溃。
1403






target>3.2 in your manifest you can use it and it will be ignored for lower versions – Blundell Aug 8 '12 at 8:07