React-native-keyboard-aware-scroll-view: Flex styling is messed up.

Created on 8 Feb 2017  Â·  7Comments  Â·  Source: APSL/react-native-keyboard-aware-scroll-view

simulator screen shot 09-feb-2017 12 46 25 am

Here is my code.

render() {
    return (
      <View style={{flex:1,backgroundColor:'black'}}>
      <KeyboardAwareScrollView viewIsInsideTabBar={false}>
        <View style={{backgroundColor:'white', flex:1}}>
          <TouchableOpacity onPress={this.props.onClosePanel}>
            <Text>{'This is my drawer'}</Text>
          </TouchableOpacity>
        </View>
        {this.renderWriteMessage()}
      </KeyboardAwareScrollView>
      </View>
    );
  }

I have given the top box flex 1. Then in that view I have created another view with flex value one. What it should do is extend that subview to bottom and the textinput should be at bottom.

If i remove KeyboardAwareScrollView element from the code it renders this.

simulator screen shot 09-feb-2017 12 50 04 am

Most helpful comment

If anyone is still having this issue try adding {flexGrow: 1} to the contentContainerStyle prop like so:

<KeyboardAwareScrollView
  contentContainerStyle={{flexGrow: 1}}
>
   // children go here
</KeyboardAwareScrollView>

All 7 comments

If you change the KeyboardAwareScrollView component to a ScrollView, you'll experience the same issue because a scroll view needs a size if its children doesn't fill the entire screen.

Please give a size to the KeyboardAwareScrollView component and ping me if that doesn't solve the issue.

I ran into this issue as well. Is there something better that KeyboardAwareScrollView is this case which will fill up all the space? (I just need to tap on the screen to remove the input focus/keyboard).

If anyone is still having this issue try adding {flexGrow: 1} to the contentContainerStyle prop like so:

<KeyboardAwareScrollView
  contentContainerStyle={{flexGrow: 1}}
>
   // children go here
</KeyboardAwareScrollView>

â–²
This should be on the doc really...

@ShayanJavadi This solved my issue of content at the bottom of the KeyboardAwareScrollView being covered when the keyboard is open. Initially I was using contentContainerStyle={{ flex: 1 }}.

If anyone is still having this issue try adding {flexGrow: 1} to the contentContainerStyle prop like so:

<KeyboardAwareScrollView
  contentContainerStyle={{flexGrow: 1}}
>
   // children go here
</KeyboardAwareScrollView>

This is awesome! Thanks @ShayanJavadi !

@ShayanJavadi Fabulous! This is exactly what I've been looking for! Thanks!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clfristoe picture clfristoe  Â·  4Comments

TylerNRobertson picture TylerNRobertson  Â·  4Comments

snksergio picture snksergio  Â·  3Comments

yasaricli picture yasaricli  Â·  3Comments

diegorodriguesvieira picture diegorodriguesvieira  Â·  4Comments