-
Notifications
You must be signed in to change notification settings - Fork 24.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in KeyboardAvoidingView on Android #11681
Comments
I encounter the exam same problem. Have you found a fix? |
We're also seeing this and have for a few RN versions now |
I had the same problem. The bug was solved after removing this.keyboardDidShowListener = DeviceEventEmitter.addListener('keyboardDidShow', this.keyboardDidShow.bind(this));
this.keyboardDidHideListener = DeviceEventEmitter.addListener('keyboardDidHide', this.keyboardDidHide.bind(this)); |
I got bitten by this on android. My workaround was to edit
And only use |
I've noticed that not specifying |
This is fixed/explained in the upcoming release (v0.42) of RN e3d4ace |
@djw27 that fix does not solve a problem :/ |
@jagi I'm having the same problem, Did you fix it ? |
@pgonzalez-santiago no I didn't fix it so far. I'm just not using this view for Android for now, so there is at list no extra padding added. But it still hides input field when keyboard opens, and until I write something it's not visible. I hope it will be fixed in the future versions of RN |
@jagi, Doh! thanks. |
The only solution I found for now is to define keyboardVerticalOffset and put everything in a ScrollView
|
I solved this problem a few months ago simply wrapping my TextInput with
Unsure when it stopped working properly but absolutely nothing i do to it makes a difference on Android unfortunately. Running RN 0.43.1. |
It is by no means a fix, but have you tried making your own KeyboardAvoidingView? I had to create a chatview for a project of mine and it works like a charm, maybe this will help you:
Of course you will still need to implement note the:
Funny enough, when I tried to use |
I ended up using |
For me it was solved using |
Even stranger fix. If I don't set a container view for Android it works but breaks on iOS. For example:
|
For me, if I don't specified |
@martinezguillaume it doesn't quite work the same without the behavior prop. It only looks right if KeyboardAvoidingView is a full-screen view. If the KeyboardAvoidingView is nested in a view with a tabbar fixed to the bottom, for instance, the intended behavior is for the keyboard to hide the tab bar and push up the KeyboardAvoidingView. This works on iOS (with behavior='padding' ) but does not work if you remove the behavior prop (on either platform) |
@eflath I've got it working quite nicely with a react navigation TabNavigator:
I don't yet understand why 25 works. My tab bar is 50. I'm half anticipating finding out that it shouldn't be 25 and should be something else, but atm it seems to work. |
Any update here ? |
Same issue here, keyboard avoiding view seems a bit unpredictable - probably the biggest pain point faced with core react native right now. Setting null behaviour for android and an arbitrary padding for ios has given me the result I wanted in the end |
Seems RN has a few ways to solve this, such as changing the KeyboardAvoidingView behavior to specify a negative Until it's fixed, the only stable solution appears to be using "adjustResize", which of course causes other problems, e.g. when using a bottom navbar (the navbar will be resized along with everything else). So... any updates about this? |
Re. Android + navbar -- the solution I've got working is to have the navbar component listen to the keyboard and simply hide itself when the keyboard is up. Works very nicely. I was experiencing very inconsistent behaviour and found that the way I'd set up my splash screen in AndroidManifest.xml was the cause: https://medium.com/@jtewright/setting-the-configchanges-and-windowsoftinputmode-on-the-splashactivity-caused-problems-with-71b937ee425b Otherwise I've found I more or less need a bit of a custom set up for each scenario. |
Hey Guys My solution is very simple.
|
@Clovs This actually worked ! , however to run successfully on android I needed to change behavior to "padding" in both platforms |
I'm on 0.53.0... I hate bots. |
Needs to be reopened as this issue is present in 0.53.0 |
We need this... really! This plays an important role in mobile app development. |
Really hope this gets prioritised - keyboard handling is always such a nightmare |
This ended up being my problem: #12980 Apparently, If at any point you app hides the status bar, all bets are off with your |
In my case, I was wrapping a login form in a
And then wrapped my form content in this wrapper:
And the padding looks perfect on both devices. Not sure if this works in other cases though. |
Iam using rn0.38 and got this problem too. But for me the statusbar is getting pushed out of the screen. The doesnt get resized. No matter which combination of |
Implementing for cross-platform keyboard avoiding scenarios has been an absolute nightmare for me. How can we move a good solution along here? |
Here's what we're doing for our cross-platform solution. it's been working fine for a long while: In place of KeyboardAvoidingView, we use our own component that looks like
Then make sure In the AndroidManifest.xml you have
So in other words we're using the react-native KeyboardAvoidingView for iOS but a plain old view on Android. As others have mentioned, the components who use the KeyboardAvoidingView should be the ones inside the Tab Navigator. This way the padding will be applied to the child page and the keyboard will properly cover the tabbar. |
For me works by passing
|
For those wondering, there is an "enabled" prop that can be used to disable the component on specific platform
|
My solution
.... |
@react-native-bot please reopen, still not working on newest release... |
For me the reason where my styles. If I gave the
It didn't work. But when I changed |
Same here, when i added justifyContent:'flex-end' it worked |
This problem still persists... I've tried all of the solutions but it seems I cant make Android to work... |
I got the same error! |
I got the same error and this saved me: import { Platform } from 'react-native';
<KeyboardAvoidingView
style={styles.yourStyle}
behavior='padding'
keyboardVerticalOffset={
Platform.select({
ios: () => -100,
android: () => -120
})()
}
>
...
</KeyboardAvoidingView> Change those values to fit your necessities on your platform, whether android or iOS |
Same here only justifyContent : 'center' and 'flex-end' works probably. 'space-between' is trying to pull up but not working |
By the way justifyContent : 'space-evenly' solved my issue |
This is working for me on both Platforms:
|
This works with a smooth animation on iOS and works in Android.
For example: here is a KeyboardAvoidingScrollView
|
I think this is the best workaround: |
I tried a bit of everything here and this is currently working for me on iOS and Android API 28, Pixel 3 as well as API 27, Nexus 6P. The keyboardVerticalOffset calculation is just a height percentage, so hp(20) is 20 percent of the window height (-120 for example).
|
it's works for me. |
this does work, but android:windowSoftInputMode="stateAlwaysVisible" means that the keyboard will be up every time your app initially launches. I was able to get it working instead by using your answer + adjustUnspecified instead of stateAlwaysVisible. |
This approach works sometimes for me. However, the keyboard frequently hides immediately after being shown. Does anyone have any advice on what to experiment with? Thank you.
|
Description
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:
Additional Information
The text was updated successfully, but these errors were encountered: