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

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

在 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 测试): enter image description here

但在 Huawei P9 Lite (Marshmallow) 中没有效果: enter image description here

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

注意 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/

相关文章:

Android avd 模拟器 - 如何在 config.ini 文件中保存 "Do you want to save the current state for the next quick boot?"

Android:Dialog中的EditText不会拉起软键盘

java - Activity 主题不变

安卓 "?colorPrimary"与 "?attr/colorPrimary"?

android - firebase 和 google play 服务无法解决异常

android - 使用 HTML 构建 Android 应用程序

android - 计算两个日历日期之间的天数差异

java - 我的问题是为什么按下按钮时我输入的文本不会显示在另一个 TextView 中?

java - 如何修复 EditText 的 getText 方法的重写

android - 添加到 Layout 的 View 继承父级的样式