Bug in KeyboardAvoidingView on Android
See original GitHub issueDescription
Hi, there is a problem with KeyboardAvoidingView on Android which is best presented by the screenshots below:
Without keyboard:
With keyboard:
It just adds too much padding to the view. On iOS it works correctly. I’ve also tried different behaviors: height
, position
but with the same effect.
Reproduction
Here is my JSX:
<KeyboardAvoidingView behavior="padding" style={{
flex: 1
}}>
<View style={{
flex: 0,
height: 50,
backgroundColor: 'skyblue'
}}>
<Text>Header</Text>
</View>
<ScrollView style={{
flex: 2,
padding: 10
}}>
<Text>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</Text>
</ScrollView>
<View style={{
flex: 0,
height: 50,
backgroundColor: 'orange'
}}>
<TextInput
style={{
marginLeft: 10,
height: 50
}}
ref="input"
placeholder="Your message here..."
returnKeyType="send"
underlineColorAndroid="transparent"
/>
</View>
</KeyboardAvoidingView>
Additional Information
- React Native version: 0.39.2
- Platform: Android
- Operating System: MacOS
Issue Analytics
- State:
- Created 7 years ago
- Reactions:97
- Comments:77 (3 by maintainers)
Top Results From Across the Web
KeyboardAvoidingView not Working Properly - Stack Overflow
This is a known issue with KeyboardAvoidingView and Android. There are multiple ways to address this issue. React Native documentation says:.
Read more >keyboard avoiding view not working ios - You.com
The behavior is relatively normal on Android, but is not working at all on iOS. ... Describe the bug KeyboardAvodingView is not working...
Read more >KeyboardAvoidingView - React Native
Specify how to react to the presence of the keyboard. Android and iOS both interact with this prop differently. On both iOS and...
Read more >[Solved]-KeyboardAvoidingView padding bug-React Native
Coding example for the question KeyboardAvoidingView padding bug-React Native. ... Different lineHeight on Android / iOS using React Native ...
Read more >How to fix KeyboardAvoidingView in React Native?
KeyboardAvoidingView is kind of difficult to make it right in both ios and android, let's see how we can fix that. Tagged with...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Hashnode Post
No results found
Hey Guys
My solution is very simple. KeyboardAvoidingView is englobing my
<Router>
and writen just one time in my application See below:I got bitten by this on android. My workaround was to edit
AndroidManifest.xml
:And only use
KeyboardAvoidingView
on iOS. YMMV. Would of course be very nice if KeyboardAvoidingView worked perfectly on both platforms 😃.