[英]Keyboard blocking textinput with Scrollview and KeyboardAvoidingView in react native
[英]keyboardAvoidingView keyboard Top white space is not removed in React native code
我正在嘗試刪除鍵盤中存在的空白區域,同時運行反應本機代碼我已經嘗試在 AndroidManifest.Xml 文件和 keyboardVerticalOffset 中使用“adjustResize”,“adjustPan”,“adjustNothing”基於 plateform.Select 和行為也給出了填充,高度這些是我正在嘗試刪除我的代碼。上面的代碼和我正在使用的樣式,請找到問題並解決我的問題EmulatorImage KeyboardIssue
<SafeAreaView
style={{
backgroundColor: 'white',
height: windowHeight,
}}>
<LinearGradient
colors={['#234590', '#0093ad', 'white', 'white']}
locations={[0, 0.1, 0.2, 0.5]}>
<View
style={{
backgroundColor: 'white',
marginTop: windowHeight * 0.065,
// height: windowHeight - (windowHeight * 0.065) - (windowWidth * 0.042),
borderTopRightRadius: windowHeight * 0.032,
borderTopLeftRadius: windowHeight * 0.032,
padding: windowWidth * 0.042,
}}>
<KeyboardAvoidingView
enabled
keyboardVerticalOffset={Platform.select({ios: 80, android: 100})}
behavior={Platform.OS === 'ios' ? 'padding' : null}>
<ScrollView>
<View
style={{
borderRadius: TextFieldCornerRadius,
height: TextFieldHeight,
borderColor: '#d9d9d9',
backgroundColor: 'white',
borderWidth: 1,
flexDirection: 'row',
justifyContent: 'space-between',
}}>
<TextInput
style={{
paddingLeft: windowWidth * 0.03,
paddingRight: windowWidth * 0.03,
paddingVertical: 0,
flex: 1,
fontSize: TextFieldFontSize,
}}
/>
</View>
</ScrollView>
</KeyboardAvoidingView>
</View>
</LinearGradient>
</SafeAreaView>;
使用 KeyboardAvoidingView,您可以這樣做以避免輸入字段被隱藏的問題。
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
style={{ flex: 1 }}>
<View style={{ flex: 1 }}>
// your code here
</View>
<KeyboardAvoidingView/>
我已經用 RN 0.70.5 測試過了
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.