5
我想更改操作栏(我使用Actionbar Sherlock兼容性)中的SearchView中闪烁光标的颜色。直到现在我已经设法改变EditText元素的光标颜色。 This SO post帮助我实现这个目标,我使用了的EditText样式看起来是这样的:在SearchView中自定义光标颜色
<style name="CustomTheme" parent="Theme.Sherlock.Light">
<item name="android:editTextStyle">@style/edittext_style</item>
</style>
<style name="edittext_style" parent="@android:style/Widget.EditText">
<item name="android:textCursorDrawable">@drawable/red_cursor</item>
</style>
红色指针看起来是这样的:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient android:startColor="@color/darkRed"
android:endColor="@color/darkRed" />
<size android:width="1dp" />
</shape>
我也来看看执行SearchView小部件和我一样,虽然它使用AutoCompleteTextView作为文本输入。由于AutoCompleteTextView是从EditText小部件派生的,我不太明白为什么样式适用于EditText,但不适用于AutoCompleteTextView(因此适用于SearchView)。
有没有人设法改变SearchView小部件中光标的颜色?
你只需要重写属性的android:textCursorDrawable在SearchAutoCompleteTextView主题应该有效。 – MaTriXy 2013-03-22 06:37:38
是的,这就是我所做的。谢谢 – mvieghofer 2013-03-24 09:52:30
是否可以更改默认的颜色,但不能绘制?我已经使用了colorControlActivated,但这不仅仅改变了文字颜色...... – 2015-08-12 06:59:45