1.1.3 • Published 4 years ago

react-native-avoiding-keyboard-scroll-view v1.1.3

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

react-native-avoiding-keyboard-scroll-view

Both support android and ios

npm.io

Getting started

$ npm install react-native-avoiding-keyboard-scroll-view --save

Manual installation

iOS

Android

  1. Insert the following lines inside in AndroidManifest.xml:
    <activity
       android:windowSoftInputMode="stateAlwaysHidden|adjustResize">
    note:
    if you want set another mode in different Scenes, you can set properties dynamically in native
     public void setAdjustPan() {
              runOnUiThread(new Runnable() {
                  @Override
                  public void run() {
                      r.getCurrentActivity().getWindow()
                              .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
                                      | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
                  }
              });
          }

Usage

import { KeyboardScrollView } from 'react-native-avoiding-keyboard-scroll-view'

// TODO: What to do with the module?
class A extends Component{
  render(){
    return (
      <KeyboardScrollView
        keyboardViewOffset={30}
        renderBottomComponent={() => <View/>}
      >
          // your layout
      </KeyboardScrollView>
    )
  }
}

API

Props

All the ScrollView props will be passed.

PropsTyperequireddescription
containerStyleViewStylenostyle of container
bottomContainerStyleViewStylenostyle of then fixed bottom
keyboardViewOffsetnumbernodistance between keyboard and TexInput
renderBottomComponentFunctionnothe component of fixed bottom
scrollRefrefnoref of scroll view