zoukankan      html  css  js  c++  java
  • 通过 react-native-keyboard-aware-scroll-view 解决键盘遮盖输入框的问题

    1.安装

    yarn add react-native-keyboard-aware-scroll-view

    2.引入

    import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'

    3.调用

    <KeyboardAwareScrollView>
      <View>
        <TextInput />
      </View>
    </KeyboardAwareScrollView>

    4.常用方法

    (1)跳到自定输入框

    _scrollToInput (reactNode: any) {
      // Add a 'scroll' ref to your ScrollView
      this.scroll.scrollToFocusedInput(reactNode)
    }
    
    <KeyboardAwareScrollView innerRef={ref => {this.scroll = ref}}>
      <View>
        <TextInput onFocus={(event: Event) => {
          // `bind` the function if you're using ES6 classes
          this._scrollToInput(ReactNative.findNodeHandle(event.target))
        }} />
      </View>
    </KeyboardAwareScrollView>

    (2)监听 键盘显示或隐藏 onKeyboardWillShow 和 onKeyboardWillHide:

    <KeyboardAwareScrollView
      onKeyboardWillShow={(frames: Object) => {
        console.log('Keyboard event', frames)
      }}>
      <View>
        <TextInput />
      </View>
    </KeyboardAwareScrollView>

    5.效果图

  • 相关阅读:
    soa
    最短路径分词
    Collector
    solr params.json
    oracle第一章
    记一次web项目总结
    java.util 类 TreeSet<E>
    自定义jstl标签库
    java二维数组简单初步理解
    Java中Array的常用方法
  • 原文地址:https://www.cnblogs.com/crazycode2/p/9582390.html
Copyright © 2011-2022 走看看