Hen*_*sma 6 autocomplete highlight background-color react-native
当 TextInput 从 React Native 上已经存在的 autoCompleteType 中突出显示时,如何更改 TextInput 的背景颜色?就像这张图片上的那样

Kev*_*get 10
要自定义此自动填充背景颜色,您必须在 android 级别进行设置。
使用您选择的名称创建一个 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>
Run Code Online (Sandbox Code Playgroud)
在这里,颜色集是透明的(“@android:color/transparent”),将其替换为您的颜色。
在android/app/src/main/res/values/styles.xml中,将此行添加到您的应用程序主题中(如果您不像我的示例中那样将其称为 autofill_highlight ,请确保提供您自己的文件名)
<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>
Run Code Online (Sandbox Code Playgroud)重建您的应用程序:)
| 归档时间: |
|
| 查看次数: |
3494 次 |
| 最近记录: |