Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native-keyboard-aware-scroll-view : Page scrolls down when I start typing

Until typing everything is ok. However after starting typing page scrolls down(shifting). I am not able to solve this whatever i do...

<ImageBackground
          source={bgSrc}
          style={styles.background}
          resizeMode="cover">

         <StatusBar hidden={true} />

          <KeyboardAwareScrollView
            showsVerticalScrollIndicator={false}
            enableOnAndroid
          >

            {screenToShow}

          </KeyboardAwareScrollView>

</ImageBackground>

const styles = StyleSheet.create({
  container: {
    width: '100%',
    height: height,
    backgroundColor: '#555',
  },
  background: {
    flex: 1,
    width: null,
    height: null,
    justifyContent: 'center',
    alignItems: 'center'
  }
});

before typing, it's looking perfect

After typing in the password field page moves down as u see:

after typing, it scroll down

like image 864
Dhaval Panchani Avatar asked Feb 03 '26 22:02

Dhaval Panchani


1 Answers

This library is always a bit janky. Try a configuration like this:

<KeyboardAwareScrollView
    style={{ backgroundColor: 
    themeColors.boxPrimaryBackground, flexGrow: 1 }}
    contentContainerStyle={{ width: '100%', margin: 0 }}
    scrollEnabled={true}
    extraScrollHeight={-125}
    extraHeight={10}
    keyboardOpeningTime={Number.MAX_SAFE_INTEGER}
    showsVerticalScrollIndicator={false}
    keyboardShouldPersistTaps={'handled'}
>
   // add scroll content here
</ KeyboardAwareScrollView>

The thing you really need to add is the keyboardOpeningTime={Number.MAX_SAFE_INTEGER}. It has something to do with the animation inside the library. Good luck hope this helps.

like image 188
Jo Momma Avatar answered Feb 05 '26 11:02

Jo Momma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!