React Native KeyboardAvoidingView covers last text input

后端 未结 4 937
遥遥无期
遥遥无期 2021-02-01 05:08

I\'m using React Native\'s Keyboard Avoiding View with the behavior set to padding (testing on Android).

I have multiple TextInputs on my screen. When I click the final

4条回答
  •  难免孤独
    2021-02-01 05:50

    To add to @Maxwell's answer, sometimes you may need to scroll further than the end of the scroll view to get a component into view, since the added padding is not the full height of the keyboard. Full example below using scrollTo() with y offset as the height of the text input.

    import React, { Component } from 'react'
    import {
        KeyboardAvoidingView,
        ScrollView,
        View,
        TextInput
    } from 'react-native'
    
    
    export default class Test extends Component {
        render() {
            return (
                
                  
                        
                        
                        
                        
                         this.refs['scroll'].scrollTo({y: 60})}/>
                  
                
            )
        } 
    }
    

提交回复
热议问题