【问题标题】:How to change cursor and pointer color in Huawei P9 Lite如何在华为 P9 Lite 中更改光标和指针颜色
【发布时间】:2016-09-26 21:03:15
【问题描述】:

使用 Login Activity 模板和 Android Studio 的 minimum 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 能够生效(用棉花糖和牛轧糖测试):

但在Huawei P9 Lite(棉花糖)中无效:

我应该怎么做才能使光标+指针颜色可移植?

注意colorControlActivated有同样的问题,不仅仅是colorAccent。

[更新]

用小米米3测试,没有这个问题。 android:textCursorDrawable="@drawable/fb" 对于这 3 台设备具有相同的行为(即只有 Huawei P9 Lite 不工作)。

【问题讨论】:

    标签: android android-edittext android-styles android-textinputlayout huawei-mobile-services


    【解决方案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. 尽管如此,Huawei P9 Lite 仍然无法使用您的代码使光标颜色生效,但 LG Nexus 5X 没有问题。
    【解决方案2】:

    尝试将android:imeOptions="actionNext" 添加到EditText。它帮助到我。

    【讨论】:

    • 感谢您的回答,但我无法重现它来测试您的回答,看来华为 P9 Lite 修复了该错误。
    猜你喜欢
    • 1970-01-01
    • 2016-02-29
    • 2017-06-08
    • 2016-06-15
    • 2017-12-26
    • 2016-06-05
    • 2015-05-28
    • 1970-01-01
    • 2012-02-07
    相关资源
    最近更新 更多