- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个TextInput
,其backgroundColor
为'rgba(255,255,255,0.16)'
,如下所示:
零食示例:https://snack.expo.io/rkEhXn6Nr
import * as React from 'react';
import { TextInput, View, StyleSheet } from 'react-native';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<TextInput
style={styles.paragraph}
value={"bleep bleep bleep bleep"}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: 'green',
},
paragraph: {
padding: 24,
margin: 24,
fontSize: 24,
textAlign: 'center',
backgroundColor: 'rgba(255,255,255,0.16)',
},
});
看起来好像有一个具有该背景颜色的 View (没有)和一个也包含该背景颜色的文本元素。我怎样才能只让“ View ”具有该背景颜色?在 Android 上看起来不错:
最佳答案
此问题仅发生在 iOS 上,因为它被用作性能调整以避免 Alpha 混合。在 iOS 设备上,<Text/>
自动获取与父 View 相同的背景颜色。有关颜色继承的更多信息,您可以查看此 issue on github 。
在您的具体情况下,您正在将背景颜色应用于文本容器,并且意外地也应用于文本本身。这就是为什么你会得到“突出显示”的文本。我可以使用简单的文本组件轻松地重新创建此行为。请看下面的法师:
要克服这个问题并拥有跨平台工作解决方案,您需要添加一个围绕 TextInput 的 View ,并在那里应用背景颜色(和其他容器样式)。
代码:
<View style={styles.container}>
<View style={styles.textContainer}>
<TextInput
style={styles.paragraph}
value={"bleep bleep bleep bleep"}
/>
</View>
</View>
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: 'green',
},
textContainer: {
margin: 24,
padding: 24,
backgroundColor: 'rgba(255,255,255,0.16)',
},
paragraph: {
fontSize: 24,
textAlign: 'center',
},
});
工作示例:
https://snack.expo.io/ByOzRyHHr
输出:
关于ios - React Native TextInput 背景颜色在设置为透明颜色时看起来是双层的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57617244/
我正在开发一个应用程序,其中日期以 yyyy-mm-dd 形式传递,但向客户端显示为 mm-dd-yyyy(美国客户端)。 我正在使用 jQuery 日期选择器在报告中选择起止日期,并希望将日期显示为
当传递道具可编辑=FALSE时,反应原生更改文本颜色。。如何更改文本输入颜色?我已经阅读了文档https://reactnative.dev/docs/textinput,但没有得到帮助
我有一个 ScrollView 到 TextInput 控件。 单击 TextInput 时,键盘会按预期出现。如果我在 View 区域中的 TextInput 外部单击,键盘
在关闭键盘或按其他地方后,如何摆脱文本输入中的光标? 这就是我所有的 TextInput: 最佳答案 我知道这个问题有点老了,但只要改进 Martin 的回答你就可以做到: componentDid
所以我会试着解释我的场景。 我有一个单行 TextInput .当用户是 onFocus ,文内TextInput可以长于 TextInput本身。 但是,当用户不再onFocus ,Android
这真的很烦人,当我在一个 TextInput 中写入文本时,我点击另一个 TextInput 以在键盘准备好时获得焦点,但它只会隐藏键盘。如何克服这种行为?我只想点击 TextInput 并立即准备好
我想知道在 python 和 Kivy 中是否可以像在 HTML/CSS 中那样自定义 TextInput 小部件。有什么方法可以直接在我的 CustomTextInput(TextInput) 类中
有没有办法做到这一点,如果用户到达 textInput 字段上“行”的末尾,它会在下一行继续并增加文本框的高度,以便他们可以看到他们输入的全部内容?现在,文本继续在同一行上,使首先输入的内容不再可见。
我已经为 TextInput 创建了公共(public)类并多次使用它,但它的事件句柄使用相同的方法。我想在 textInput 中填充数据后处理数组数据。 这里添加了多个textField和单个ha
我是一个新手,无法做出本地 react ,并正在努力解决以下问题。我正在执行更新功能,一旦选择了用户,该用户的数据就会填充到其专用字段 TextInput 中,例如 given_name、family
使用 React Native TextInput,在键盘可见的情况下点击后退按钮(屏幕截图中的红色 1)时,可以稍后编辑 TextInput 值。但是,当点击检查/输入图标(屏幕截图中的红色 2)时
我想要一个输入文本,一旦达到最大值就自动跳转到另一个输入文本字段。 这是示例文本字段。 Identification card: - - 如何让输入的文本字段在第一个文本字段达到最大数量后立即跳
我遇到了这种非常奇怪的行为.. 这是我的代码的简化版本: DOWN = 40; UP = 38; $(document).on("keydown", "#text_input", function(e
当我点击它时,我有一个名为电子邮件或用户名的文本输入,它不显示我键入的值,我认为这是因为屏幕尺寸,无论如何我可以调整 Textinput 以便当我单击它,全文输入显示,我可以看到我输入的值。它下方的其
我的 app.js 中有一个 TextInput ,但它位于页面中间,但我希望它位于页面顶部,我的意思是就在通知栏下方,请问我该怎么做 const BackStyles
我正在尝试使用kv语言重做我已经完成的程序。第一个是用 python 完成的。现在,当我使用 kivy 语言时,我无法从用户界面中获取任何内容。在这个例子中。当条形码文本更改时,它应该更新它的文本属性
我在使用 TextInput 时遇到问题 预期的行为是,当我点击它时,它会聚焦并显示键盘,当我在它周围点击时(除了输入之外的任何地方),TextInput应该模糊并且键盘会消失。目前这不会发生,无论我
我有一个问题,当我在 TextInput 中输入垃圾邮件并单击按钮提交并清除文本时,它变得迟缓并且不会立即清除 TextInput 中的文本。当我在屏幕中有很多内容(如 Lorem Ipsum 文本)
我正在使用函数更新 onChangeText 事件上的 TextInput 值。如果我在函数中状态更新后控制台记录该值,它会打印更新后的值,但不会在输入中显示更新后的值。 errorMessages
在 Powerapp 应用程序中,我有屏幕,其中包含 1:“文本输入”,输入城市名称 2 : 当我点击清除按钮时,如何清除文本输入的值? Click here for more details of
我是一名优秀的程序员,十分优秀!