如何在华为P9 Lite中更改光标和指针颜色

3

使用 Android Studio 中的 登录活动(Login Activity) 模板,选择最低 SDK API 14 创建项目,然后在 styles.xml 中将 colorAccent 自定义为粉色:

<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 上测试):enter image description hereHuawei P9 Lite(Marshmallow)无效:enter image description here 我该怎么做才能使光标和指针颜色可移植?
请注意,colorControlActivated 也存在同样的问题,不仅限于 colorAccent[更新]Xiaomi Mi 3上测试,没有这样的问题。android:textCursorDrawable="@drawable/fb" 对于这三个设备具有相同的行为(即仅 Huawei P9 Lite 不起作用)。
2个回答

1
你可以尝试这样做:
定义一个可绘制资源: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"

  1. 这只能改变光标(竖线)的颜色,不包括指针(水滴形状)的颜色。
  2. 然而,使用您的代码,华为P9 Lite仍然无法生效,但LG Nexus 5X没有问题。
- 林果皞

0
尝试在EditText中添加android:imeOptions ="actionNext"。它对我有帮助。

谢谢你的回答,但我无法复现它以测试你的答案,似乎华为P9 Lite已经修补了这个漏洞。 - 林果皞

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接