Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do not move view when keyboard shows in React Native?

I have two elements in the screen. The first one is Scrollview with flex and the other is View with fixed height. When keyboard shows up View element goes up.

How to achieve element does not go up?

Ok, here is the code:

<View style={{flex: 1}}>
    <Scrollview style={{flex: 1}}>
        <TextInput />
    </Scrollview>
    <View style={{height: 24}}>
         Two buttons here...
    </View>
</View>

Here is the screenshot: enter image description here

Just want that two footer buttons do not go up when keyboard is shown.

like image 809
Umid Boltabaev Avatar asked Dec 23 '22 20:12

Umid Boltabaev


1 Answers

You can try following code. It may resolve your issue

<KeyboardAvoidingView
    behavior={Platform.OS == "ios" ? "padding" : "height"}
    keyboardVerticalOffset={Platform.OS == "ios" ? 0 : 20}
    enabled={Platform.OS === "ios" ? true : false}>

  <Text>Hello</Text>
  <Text>World</Text>

</KeyboardAvoidingView>
like image 110
Vishal Dhanotiya Avatar answered Dec 26 '22 18:12

Vishal Dhanotiya