以编程方式更改Android的EditText光标指针颜色

ale*_*rdi 6 android pointers colors android-edittext

所以,我已经搜索了很多,但我找不到任何东西,如果这最终成为重复我很抱歉,但我想伪装EditText的光标指针的颜色,用于移动光标

在此输入图像描述

我已经设法改变了光标的颜色,但它不会影响指针,它似乎只响应accentColor.

我很确定它是可能的,因为我记得看到一个应用程序执行它,它有指针和对话框中的所有元素根据您选择的颜色更改颜色而不更改对话框下方视图的强调颜色.

请帮忙 :)

Cho*_*hol 8

您只能为此EditText创建自己的样式/主题并更改ColorAccent:

<style name="EditTextColorCustom" parent="@style/AppBaseTheme">
        <!-- Customize your theme here. -->
        <item name="colorAccent">@color/colorAccent</item>
    </style>
Run Code Online (Sandbox Code Playgroud)


MUH*_*BAN 5

您可以这样在style.xml中创建新样式来实现

<style name="CustomEditTextTheme" parent="TextAppearance.AppCompat">
    <item name="colorAccent">@color/primary_dark_material_dark</item>       
</style>
Run Code Online (Sandbox Code Playgroud)

然后在EditText标签中使用此

style="@style/CustomEditTextTheme"
Run Code Online (Sandbox Code Playgroud)

  • 而不是style = ...我写了`android:theme =“ @ style / CustomEditTextTheme”`。 (3认同)