Skip to content
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

extra bottom space #463

Open
donmezemre opened this issue Oct 23, 2020 · 17 comments
Open

extra bottom space #463

donmezemre opened this issue Oct 23, 2020 · 17 comments

Comments

@donmezemre
Copy link

Reproduce
720p

Problem
when we focused a text input and scroll to bottom, an extra space is added at the bottom. besides that, android and ios behaves different.

Questions
why does this happen?
how to avoid from this behave?

and thank you

Code That I Used*
Screen Shot 2020-10-23 at 14 54 41

@aleciogomes
Copy link

Your Android issue might be related with your android:windowSoftInputMode in your AndroidManifest.xml. It seems to be adding double keyboard-height padding. Also, is there any reason to use enabledOnAndroid? Android seems to handle well these kind of situations without any configuration.

The iOS extra value seems to be the bottom SafeAreaInset. Not sure why, tho. (It seems the same height value os the pink bottom area).

image

@donmezemre
Copy link
Author

donmezemre commented Oct 26, 2020

for android:
android:windowSoftInputMode was adjustResize by default. but if i use this default value the keyboard focus losing suddenly when the text input focused. I had to change adjustPan to avoid lose focus.

@Soliman13
Copy link

Is this issue still being tracked? As I encounter the same issue.

@donmezemre
Copy link
Author

i am telling with sadness, yes

@devinjameson
Copy link

Having the same issue on iOS.

@devinjameson
Copy link

This may be a safe area inset issue on iOS. You may be able to get the bottom safe area from a library like react-native-static-safe-area-insets and set the extraScrollHeight to the negative of that value.

@WhidRubeld
Copy link

At the moment disabling android insert will solve this problem
enableOnAndroid={false}

@galbenyosef
Copy link

galbenyosef commented May 10, 2021

This may be a safe area inset issue on iOS. You may be able to get the bottom safe area from a library like react-native-static-safe-area-insets and set the extraScrollHeight to the negative of that value.

try
import { useSafeAreaInsets } from 'react-native-safe-area-context';
let insets = useSafeAreaInsets();

<KeyboardAwareScrollView
extraScrollHeight={-insets.bottom}
contentContainerStyle={{ flexGrow: 1 }}
.../>

occurs only on ios
works for me.

@devinjameson
Copy link

devinjameson commented May 10, 2021

This may be a safe area inset issue on iOS. You may be able to get the bottom safe area from a library like react-native-static-safe-area-insets and set the extraScrollHeight to the negative of that value.

try

import { useSafeAreaInsets } from 'react-native-safe-area-context';

let insets = useSafeAreaInsets();

<KeyboardAwareScrollView

extraScrollHeight={-insets.bottom}

contentContainerStyle={{ flexGrow: 1 }}

.../>

occurs only on ios

works for me.

@galbenyosef This looks great. If you want to avoid using a hook (no need for a hook in this case, it's just a static value), you can use react-native-static-safe-area-insets to grab the bottom inset.

@lucasriondel
Copy link

@devinjameson 's solution worked perfectly. thanks a lot !

@svmszcck
Copy link

On Android try to set extraHeight to 0(According to the docs Default is 75)

@Chifaa-Bouzid
Copy link

@devinjameson's solution worked perfectly fine for me, thanks a lot. I just modified it a bit to correspond to how I want it to look --> extraScrollHeight={-(insets.bottom)*2.3}

@bombillazo
Copy link

Adding to the solution provided previously, I use useBottomTabBarHeight() + a custom useKeyboardHeight() hook:

extraScrollHeight={-(keyboardHeight + bottomTabBarHeight)}

@kitkatMielPineda
Copy link

kitkatMielPineda commented Sep 8, 2022

I got a solution on this.. Tested on iPhone 13, iPhone 13 Pro Max, iPhone 6s, iPhone SE (3rd generation) and android.

try:

import React, {useEffect, useState} from 'react';
import { useWindowDimensions} from 'react-native';
import useKeyboardHeight from 'react-native-use-keyboard-height'


  const [contentBottom, setContentBottom] = useState(0);
  const [keyboardActive, setKeyboardActive] = useState(false)

  const {height} = useWindowDimensions()
  const keyHeight = useKeyboardHeight()

  useEffect(()=>{  
    if (keyboardActive){
      const diff = (parseFloat((height - keyHeight)/2))
      setContentBottom(diff)
    } else{
      setContentBottom(0)
    }
  },[keyHeight, keyboardActive]
  
<KeyboardAwareScrollView
            keyboardOpeningTime={0}
            enableResetScrollToCoords
            onKeyboardWillHide={() => setKeyboardActive(false)}
            onKeyboardWillShow={()=>setKeyboardActive(true)}
            contentInset={{ bottom: contentBottom }}
            automaticallyAdjustKeyboardInsets={true}
            automaticallyAdjustContentInsets={false}
          >

Previous

with extra white space at the bottom of the background image and before the keyboard for iPhone 13
Screen Shot 2022-09-08 at 12 04 24 PM

Changes

no extra white space anymore
Screen Shot 2022-09-08 at 10 32 29 PM
Screen Shot 2022-09-08 at 10 18 06 PM

goodnight everyone!

@vishalrathod817
Copy link

extraScrollHeight={-insets.bottom}
contentContainerStyle={{ flexGrow: 1 }}

this working for me.... thanks

@Nidhi-Kayasth-RXO
Copy link

You need to set these properties to remove extra spacing.
This is working for me.

<KeyboardAwareScrollView
automaticallyAdjustContentInsets={true}
keyboardShouldPersistTaps='always'
scrollEventThrottle={10}
resetScrollToCoords={{ x: 0, y: 0 }}
contentInset={{ top: 0, bottom: 0 }}

@MussadiqAli
Copy link

MussadiqAli commented Oct 18, 2024

I've tried all aboved mentioned solutions but no one is worked.
Finally this is worked for me:

<KeyboardAwareScrollView
        style={{
          marginBottom:
            keyboardHeight > 0 ?  -keyboardHeight : 0,
        }}
 >

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests