更改react-native上textInput高亮显示的背景颜色(自动完成) [英] Change the background color of textInput highlight (autocomplete) on react-native

查看:324
本文介绍了更改react-native上textInput高亮显示的背景颜色(自动完成)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当从响应本机上已经存在的autoCompleteType中突出显示TextInput时,如何更改TextInput的背景颜色?喜欢这张图片

How can I change this background color of TextInput when it got highlight from the autoCompleteType that already exists on react native? like on this image

推荐答案

要自定义此自动填充bg颜色,您必须将其设置为android级别.

To customize this autofill bg color, you have to set this at android level.

  1. 使用您选择的名称创建xml文件,例如 android/app/src/main/res/drawable 中的 autofill_highlight.xml

将此代码放入其中:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@android:color/transparent" />
</shape>

在这里,颜色集是透明的("@android:color/transparent"),将其替换为您的颜色.

Here, the color set is transparent ("@android:color/transparent"), replace it with your color.

android/app/src/main/res/values/styles.xml 中,将此行添加到您的应用主题中( 请确保提供您自己的文件名(如果您不像我的示例那样将其命名为autofill_highlight )

In android/app/src/main/res/values/styles.xml, add this line to your app theme (make sure to provide your own file name if you don't call it autofill_highlight like in my example)

<resources>
     <!-- Base application theme. -->
     <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

         <!-- ... your other theme customization ...  -->

         <!-- ADD THE FOLLOWING LINE -->
         <item name="android:autofilledHighlight">@drawable/autofill_highlight</item>

    </style>
</resources>

  • 重建您的应用程序:)

  • Rebuild your application :)

    这篇关于更改react-native上textInput高亮显示的背景颜色(自动完成)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆