- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的代码中有两个 TextInput
。其中之一我将其 showSoftInputOnFocus
设置为 true
,我想在它聚焦时显示键盘。另一个我将它的 showSoftInputOnFocus
设置为 false
,我不想在它聚焦时显示键盘。
<View>
<Text style={_label}>Field1</Text>
<TextInput
value={value1}
showSoftInputOnFocus={false}
keyboardType="numeric"
/>
</View>
<View>
<Text style={_label}>Field2</Text>
<TextInput
value={value2}
autoFocus={true}
showSoftInputOnFocus={true}
/>
</View>
当第二个 TextInput
获得焦点时,键盘显示。然后我按下第一个 TextInput
,它聚焦了,但键盘仍然在屏幕上,它没有关闭。
我尝试将 onBlur={Keyboard.dismiss}
添加到第二个 TextInput
。当我将光标从第二个 TextInput
切换到第一个时,键盘确实被隐藏了,但第一个 TextInput
没有获得焦点。我必须再次按下第一个 TextInput
以使其聚焦。
如何让第一个 TextInput
在我按下时立即获得焦点?
最佳答案
ScrollView
有一个名为 keyboardShouldPersistTaps
的属性,它会在显示键盘时更改触摸行为。尝试在主视图中添加 ScrollView
:
<View>
<ScrollView keyboardShouldPersistTaps='always'>
...
</ScrollView>
</View>
关于android - React-Native TextInput showSoftInputOnFocus 效果不佳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58145749/
我的代码中有两个 TextInput。其中之一我将其 showSoftInputOnFocus 设置为 true,我想在它聚焦时显示键盘。另一个我将它的 showSoftInputOnFocus 设置
我正在设计一个应用程序,我在 AndroidManifest.xml 中设置了 android:windowSoftInputMode="stateHidden" 防止键盘烦人地弹出。但我希望在某个动
我是一名优秀的程序员,十分优秀!