Geo*_*org 11 android cursor android-edittext
我必须在我的应用程序中使用带有白色背景的EditText.我在我的theme.xml文件中这样做了
<style name="myEditText" parent="@android:style/Widget.EditText">
<item name="android:background">#ffffffff</item>
<item name="android:textColor">#ff000000</item>
</style>
Run Code Online (Sandbox Code Playgroud)
现在的问题是光标仍然是白色,因此不可见.我做了一些谷歌搜索,并在StackOverflow上找到了这个问题: 设置EditText光标颜色
它的方式是android:textCursorDrawable关键.但是这个密钥确实只能用于3.2目标.但我们的客户想要3.0目标,我找不到任何其他解决方案......
有什么办法可以用3.0作为目标来改变闪烁光标的颜色吗?
谢谢你的帮助:)
小智 2
我找到了答案:)
我已将主题的 editText 样式设置为:
<item name="android:editTextStyle">@style/myEditText</item>
Run Code Online (Sandbox Code Playgroud)
然后我使用以下可绘制对象来设置光标:
<style name="myEditText" parent="@android:style/Widget.Holo.Light.EditText">
<item name="android:background">@android:drawable/editbox_background_normal</item>
<item name="android:textCursorDrawable">@android:drawable/my_cursor_drawable</item>
<item name="android:height">40sp</item> </style>
Run Code Online (Sandbox Code Playgroud)
android:textCursorDrawable是这里的关键。
另请参阅 使用 XML 可绘制的垂直线