【发布时间】:2020-10-04 08:19:05
【问题描述】:
我正在开发一个使用 react native cli 制作的 react native 项目。问题是当键盘可见/活动时 TextInput 会突出显示,它会挤压视图并弄乱布局,这让我想起了 KeyboardAvoidingView 行为。尽管我在这个项目中没有使用KeyboardAvoidingView,因为所有文本输入都在屏幕的上半部分,所以它们不会被键盘覆盖。
<TextInput
style={styles.inputText}
multiline={false}
onSubmitEditing={() => Keyboard.dismiss()}
autoCapitalize="none"
autoCorrect={false}
keyboardType="number-pad"
onChangeText={numberInputHandler}
value={enteredValue}/>
inputText: {
borderBottomColor: "white",
borderBottomWidth: 2,
width: "30%",
position: "absolute",
bottom: Dimensions.get("window").height / 5,
left: Dimensions.get("window").width / 5,
color: "white",
fontSize: Dimensions.get("window").height * 0.03,
fontFamily: "Lato-Regular"
}
React Native 版本 0.61.5
测试是在 Android 模拟器和 Android 物理设备上完成的
【问题讨论】:
-
只需将 android:windowSoftInputMode="stateHidden|stateVisible|adjustPan" 添加到您希望键盘不改变任何行为的活动中的 ManifistFile 中
标签: android react-native