【发布时间】:2018-10-03 17:38:15
【问题描述】:
我在 Android 上遇到了 KeyboardAvoidingView 的问题。它适用于 iOS。我的屏幕在屏幕的上半部分有一个视图组件,可能会也可能不会影响它。我已经尝试删除这些组件中的每一个,但 KeyboardAvoidingView 仅在我删除占据屏幕 60% 的组件时才有效。此组件是来自“react-native-youtube”的 YouTube 播放器,具有 flex: 1 样式。
我的代码看起来像这样..
<KeyboardAvoidingView
behavior="padding"
keyboardVerticalOffset={200}
>
<View style={styles.first}>
<View style={styles.second}>
<TouchableHighlight />
<View style={styles.third}>
<TextInput
style={styles.textInput}
maxLength={80}
autoGrow={true}
maxHeight={130}
multiline={true}
editable={true}
onChangeText={onChange}
value={descriptionText}
autoFocus={true}
keyboardType={'default'}
autoCorrect={false}
placeholder={'Send a word'}
underlineColorAndroid={white}
selectionColor={purple}
returnKeyType={'send'}
onSubmitEditing={handleSubmit}
/>
</View>
</View>
</View>
<KeyboardAvoidingView/>
first: {
flexDirection: 'column',
justifyContent: 'flex-start',
position: 'relative',
marginTop: 0,
},
second: {
width: screenWidth,
flexDirection: 'row',
alignItems: 'center',
paddingTop: 5,
paddingBottom: 9,
},
third: {
flexDirection: 'row',
borderTopLeftRadius: 10,
borderBottomLeftRadius: 10,
paddingBottom: 5,
paddingLeft: 10,
paddingRight: 10,
width: screenWidth - 102,
minHeight: 36,
alignItems: 'center',
},
textInput: {
textAlign: 'left',
fontSize: 14,
fontWeight: '400',
flex: 1,
padding: 0,
margin: 0,
}
这里有什么可能会影响KeyboardAvoidingView 的功能吗?我已经尝试删除 behavior="padding" ,因为 React Native 文档提到删除该道具后它在 android 上效果更好。
谢谢!
【问题讨论】:
标签: android reactjs react-native textinput