我在平板电脑项目上使用Android的Holo主题时遇到了这个问题。然而,我在屏幕上有一个片段,它有一个白色背景。我在这个片段上添加了一个EditText组件。我试图通过设置Holo的背景来覆盖主题。轻主题资源。然而,我的文本光标(carat)仍然是白色的,因此在屏幕上不可见(我可以在edittext字段中隐约发现它..)。

有人知道如何让EditText使用更深的光标颜色吗?我已经尝试将EditText的样式设置为“@android:style/Widget.Holo.Light”。没有积极的结果。


当前回答

设置android:textCursorDrawable属性为@null应该导致使用android:textColor作为光标颜色。

属性“textCursorDrawable”在API级别12及更高级别可用

其他回答

你想要特定的颜色,你必须使用AppCompatEditText然后backround设置null

对我有用

<android.support.v7.widget.AppCompatEditText
    android:background="@null"
    android:textCursorDrawable="@color/cursorColor"/>

看看这个要点

注意你当前活动/片段/对话框中的colorAccent,在Styles中定义…;) 光标颜色与之相关。

唯一有效的答案应该是改变活动的主题: <项目名称= " colorAccent " > # 000000 > < /项目 你不应该使用android:textCursorDrawable @null,因为这只关心光标本身,而不是针下面的光标,如果你想拖动该光标。主题化解决方案是最重要的解决方案。

你可以在布局中使用下面的代码

android:textCursorDrawable="@color/red"
        android:textColor="@color/black

对我来说,我修改了AppTheme和一个值colors.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorControlNormal">@color/yellow</item>
    <item name="colorAccent">@color/yellow</item>
</style>

这是colors.xml文件

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="yellow">#B7EC2A</color>
</resources>

我拿出了android:textCursorDrawable属性@null,我放置在editText样式。当我尝试使用这个,颜色不会改变。