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

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


当前回答

editcolor.xml

android: textCursorDrawable =“@drawable / editcolor”

在xml文件中设置编辑文本背景颜色的颜色代码

其他回答

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimary</item>
    <item name="colorAccent">@color/colorAccent</item> -- change this one
</style>

转到styles.xml并更改颜色重音,这将影响编辑文本框的光标

如果使用样式和实现

colorControlActivate

将其值替换为其他颜色/白色。

Edittext cursor color you want changes your color.
   <EditText  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textCursorDrawable="@drawable/color_cursor"
    />

然后创建可绘制的xml: color_cursor

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <size android:width="3dp" />
    <solid android:color="#FFFFFF"  />
</shape>

其实比这更简单。

<style name="MyTextStyle">
    <item name="android:textCursorDrawable">#000000</item>
</style>

这适用于ICS和其他领域。我还没有在其他版本中测试过。

哇,我真的很晚才参加这个派对,但它在17天前就有活动了 我们需要考虑发布我们使用的Android版本的答案,所以目前这个答案适用于Android 2.1及以上版本 转到RES/VALUES/STYLES,添加下面的代码行,你的光标将是黑色的

    <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <!--<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">-->
    <!-- Customize your theme here. -->
    <item name="colorControlActivated">@color/color_Black</item>
    <!--Sets COLOR for the Cursor in EditText  -->
</style>

你需要在RES/COLOR文件夹中有这一行代码

<color name="color_Black">#000000</color>

为什么这么晚才发?Android已经变成了一头怪物,考虑一些分类形式可能会很好!