Skip to content

Commit

Permalink
Update README on how to fix Android keyboard
Browse files Browse the repository at this point in the history
I found this in another issue and I think it should be updated here. FaridSafi#680 (comment)
  • Loading branch information
chandlervdw authored Sep 5, 2019
1 parent bb0123a commit bee56a0
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,11 @@ If you are using Create React Native App / Expo, no Android specific installatio

- For **Expo**, there are at least 2 solutions to fix it:

- Wrap GiftedChat in a [`KeyboardAvoidingView`](https://facebook.github.io/react-native/docs/keyboardavoidingview). This should only be done for Android, as `KeyboardAvoidingView` may conflict with the iOS keyboard avoidance already built into GiftedChat, e.g.:
- Add a [`KeyboardAvoidingView`](https://facebook.github.io/react-native/docs/keyboardavoidingview) below GiftedChat, wrapped in a parent whose `flex` is 1. This should only be done for Android, as `KeyboardAvoidingView` may conflict with the iOS keyboard avoidance already built into GiftedChat, e.g.:
```
<View style={{ flex: 1 }}>
{
Platform.OS === 'android' ?
<KeyboardAvoidingView behavior="padding">
<GiftedChat />
</KeyboardAvoidingView> :
<GiftedChat />
}
<GiftedChat />
{Platform.OS === 'android' ? <KeyboardAvoidingView behavior="padding" />}
</View>
```
If you use React Navigation, additional handling may be required to account for navigation headers and tabs. `KeyboardAvoidingView`'s `keyboardVerticalOffset` property can be set to the height of the navigation header and [`tabBarOptions.keyboardHidesTabBar`](https://reactnavigation.org/docs/en/bottom-tab-navigator.html#bottomtabnavigatorconfig) can be set to keep the tab bar from being shown when the keyboard is up. Due to a [bug with calculating height on Android phones with notches](facebook/react-native#23693), `KeyboardAvoidingView` is recommended over other solutions that involve calculating the height of the window.
Expand Down

0 comments on commit bee56a0

Please sign in to comment.