在 Android Studio 中使用 Login Activity 模板和 minimum SDK API 14 创建项目,然后在 中将 colorAccent
自定义为粉红色样式.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">#FF4081</item><!-- pink color -->
</style>
LG Nexus 5X 能生效(用 Marshmallow 和 Nougat 测试):
但在 Huawei P9 Lite (Marshmallow) 中没有效果:
我应该怎么做才能使光标+指针颜色可移植?
注意 colorControlActivated
有同样的问题,不仅仅是 colorAccent
。
[更新]
用小米米3测试,没有这个问题。 android:textCursorDrawable="@drawable/fb"
对这 3 个设备有相同的行为(即只有 Huawei P9 Lite 不工作)。
最佳答案
你可以试试这个:
定义可绘制资源:cursor_green.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/green"/>
<size android:width="2dp"/>
</shape>
然后使用
将其设置为EditText
android:textCursorDrawable="@drawable/cursor_green"
关于android - 如何在华为 P9 Lite 中更改光标和指针颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39712351/