React Native Make View “Hug” the Top of the Keyboard

后端 未结 5 1965
陌清茗
陌清茗 2021-02-13 03:48

Let\'s say I have a view that is positioned absolute at the bottom of the screen. This view contains a text input. When the text input is focused, I want the bottom of the view

5条回答
  •  北恋
    北恋 (楼主)
    2021-02-13 03:53

    @jazzdle example works great! Thank you for that! Just one addition - in keyboardWillShow method, one can add event.endCoordinates.height so paddingBottom is exact height as keyboard.

        keyboardWillShow = (event) => {
        Animated.timing(this.paddingInput, {
            duration: event.duration,
            toValue: event.endCoordinates.height,
        }).start();
    }
    

提交回复
热议问题