简体   繁体   English

在react native中使用KeyboardAvoidingView时,整个内容被推高

[英]Whole contents are pushed up when using KeyboardAvoidingView in react native

I have a issue when using KeyboardAvoidingView in react native. 我在React Native中使用KeyboardAvoidingView时遇到问题。 Follow is my code: 以下是我的代码:

<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>

On Android, when I tap TextInput then upper component is pushed up and so below component is fill out the screen. 在Android上,当我点击TextInput时,上半部分被向上推,因此下半部分被填满了屏幕。 But on iOS it's Ok. 但是在iOS上也可以。

Follow is screenshot before tapping the TextInput on android: 在Android上点击TextInput之前,请遵循以下屏幕截图:

点击TextInput之前的屏幕截图

Follow is screenshot after tapping then TextInput: 点按然后输入TextInput后,跟随屏幕截图:

点击TextInput后的屏幕截图

As before I said, on iOS, everything is ok. 如前所述,在iOS上,一切正常。 How can I fix this issue on android? 如何在Android上解决此问题? Why on iOs is different from on android? 为什么在iOs上与android不同? I'm very happy to hear your advance. 听到您的进步我感到非常高兴。 Thanks. 谢谢。

For iOS you should set the "behavior" parameter of the KeyboardAvoidingView to "padding", but not for android. 对于iOS,您应该将KeyboardAvoidingView的“ behavior”参数设置为“ padding”,但对于android则不能。 I show a working example in this answer : 我在这个答案中显示了一个工作示例:

https://stackoverflow.com/a/52255480/5359812 https://stackoverflow.com/a/52255480/5359812

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Android上测试的React Native项目中使用KeyboardAvoidingView重叠 - Overlap using KeyboardAvoidingView in a React Native project tested in Android 为什么KeyboardAvoidingView在React Native中不起作用? - Why is KeyboardAvoidingView not working in React Native? React Native Keyboard 涵盖 Android 上的 TextInput KeyboardAvoidingView - React Native Keyboard covers TextInput KeyboardAvoidingView on Android React Native(Expo) KeyboardAvoidingView 在 Android 中无法点击 - React Native(Expo) KeyboardAvoidingView makes unclickable in Android 使用 React Native 在 Android 上使用 KeyboardAvoidView 推送 BackgroundImage - BackgroundImage being pushed up with KeyboardAvoidView on Android with React Native React Native - 如何使 ScrollView 中的 KeyboardAvoidingView 适用于所有设备? - React Native - How to make KeyboardAvoidingView inside a ScrollView work for all devices? 在 React Native 中,如何在 iOS 中将 KeyboardAvoidingView 与 Modal 一起使用? - In React Native, How Can I Use KeyboardAvoidingView with a Modal in iOS? 如果用 ImageBackground 包装,React Native KeyboardAvoidingView 不起作用 - React Native KeyboardAvoidingView Didn't work if wrapped with ImageBackground 改变了键盘上的组件的位置确实显示-KeyboardAvoidingView无法正常工作-[React Native] - Change the position of a Component on keyboard did show - KeyboardAvoidingView not working - [React Native] 方向更改后,React Native KeyboardAvoidingView 无法正常工作 - React Native KeyboardAvoidingView not working properly after orientation changes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM