简体   繁体   English

TextInput selectionColor属性在android上没有改变颜色

[英]TextInput selectionColor property no changing color on android

After reading the React Native documentation I understood that selectionColor was used to change the color of the cursor instead of that primary default color of android system. 在阅读了React Native文档后,我了解到selectionColor用于更改光标的颜色而不是android系统的主要默认颜色。

So I tried the following: 所以我尝试了以下方法:

<TextInput selectionColor="#2E5BFF" {...props} autoCapitalize="none" autoCorrect={false} />

The problem is that on android devices it still gets that green default color of android, on the emulator tought its fine and is showing #2E5BFF color. 问题是在Android设备上它仍然获得了android的绿色默认颜色,在模拟器上它很好并显示#2E5BFF颜色。 My android devices both have android P. 我的android设备都有android P.

Is there any known bug or am I doing something wrong here? 有没有已知的bug或我在这里做错了什么?

EDIT 编辑

I'm using Expo SDK 32.0.0 我正在使用Expo SDK 32.0.0

    <TextInput 
   selectionColor={global.COLOR.DARKBLUE}
   underlineColorAndroid={global.COLOR.ORANGE}
  autoCapitalize="none" autoCorrect={false} />

you can try this 你可以试试这个

You can set colorControlActivated in styles.xml file.Like this 您可以在styles.xml文件中设置colorControlActivated 。就像这样

<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="colorPrimary">@color/kio_turquoise</item>
    <item name="colorPrimaryDark">@color/kio_hot_pink</item>

    <!-- sets cursor color -->
    <item name="colorControlActivated">@android:color/black</item>
 </style>

because the backbone of the app is the native android application. 因为应用程序的主干是本机Android应用程序。 For more information you can refer this article. 有关更多信息,请参阅此文章。 It is very helpful. 这非常有帮助。

React native on android styling the cursor 在android上设置游标的反应原生

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM