有没有办法在react-native android中设置textInput的样式?

推荐答案

从React原生版本0.21开始,仍然无法通过视图props 设置光标 colored颜色 的样式.我已经通过在我的应用程序主题中添加自定义样式成功地设置了光标 colored颜色 的样式.

您需要将此代码放入styles.xml文件中,该文件位于React项目的android文件夹android/app/src/main/res/values/styles.xml中.

<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- typical material style colors --> 
        <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>
</resources>

请注意,这种样式是全局的,将为React原生应用程序中的所有Android TextInput视图设置光标 colored颜色 .

React-native相关问答推荐

没有给出相同价值观的时刻

如何在EXPO路由中重置导航

在 React Native 中使用 Flatlist scrollView 时的模式关闭

在 react native 平面列表中动态定位弹出窗口

最近 react-native 版本中的Unable to resolve moduledebuggerWorker 错误

React Native 获取视图相对于屏幕的绝对位置

使用带有 react-native 的 WebView 设置用户代理

使用像 React Navigation 这样的基于 JS 的导航解决方案优缺点?

如何从 React Native 应用程序打开 Google Play store ?

使用 android 的应用中心分发时应用未安装错误

无法判断模块react-native-maps:找不到名称为 default的配置

Animated.View 的样式props的Typescript定义

无法识别的 WebSocket 连接选项 `agent`、`perMessageDeflate`、`pfx`、`key`、`passphrase`... 你的意思是把这些放在 `headers` 下吗?

xcode 10错误:multiple commands produce

ReactNative TextInput 不可见 iOS

如何在 React Native 中禁用图像淡入效果?

React Native:使用百分比时将视图的宽度设置为等于其高度

当前未启用语法nullishCoalescingOperator

Android Log

使用expo react-native链接?