在本机反应中使用 KeyboardAvoidingView 时遇到问题。以下是我的代码:
<View style={styles.container}>
<View style = {styles.pagetitle_part}>
<Text style = {{fontSize: 25, color: '#ffffff'}}> Register User </Text>
<TouchableOpacity style = {{position: 'absolute', top: 30, left: 20}} onPress = {() => this.props.navigation.navigate('SignIn')}>
<Image style = {{width: 15, height: 15}} resizeMode = 'contain' source = {require('../assets/images/left_arrow.png')}/>
</TouchableOpacity>
</View>
<View style = {styles.main_part}>
<ScrollView style = {{width: deviceWidth}} showsVerticalScrollIndicator = {false}>
<KeyboardAvoidingView behavior = 'padding'>
<View style = {styles.component_input}>
<View style = {styles.title_view}>
<Text style = {styles.title_text}> Fist Name </Text>
</View>
<View style = {styles.input_view}>
<TextInput underlineColorAndroid = 'transparent' style = {styles.input_text} onChangeText = {this.handleFirstName}>{this.state.first_name}</TextInput>
</View>
</View>
<View style = {styles.component_input}>
<View style = {styles.title_view}>
<Text style = {styles.title_text}> Last Name </Text>
</View>
<View style = {styles.input_view}>
<TextInput underlineColorAndroid = 'transparent' style = {styles.input_text} onChangeText = {this.handleLastName}>{this.state.last_name}</TextInput>
</View>
</View>
... ... ...
</KeyboardAvoidingView>
</ScrollView>
</View>
</View>
在 Android 上,当我点击 TextInput 时,上部组件被向上推,因此下部组件填充屏幕。但是在iOS上没关系。
以下是在 android 上点击 TextInput 之前的屏幕截图:
以下是点击 TextInput 后的屏幕截图:
正如我之前所说,在 iOS 上,一切正常。我怎样才能在android上解决这个问题?为什么在 iOs 上与在 android 上不同?我很高兴听到你的进步。谢谢。