【问题标题】:react-native resize <ScrollView/> when keyboard is openreact-native resize <ScrollView/> 当键盘打开时
【发布时间】:2016-11-11 21:55:38
【问题描述】:

我有一个 react-native 简单的聊天应用,看起来像这样

+-----------------
|     Header     |
+----------------+
|                |
|                |
|    Messages    |
|                |
|                |
+----------------+
|   Write here   |
+----------------+

我想要实现的是,当我打开键盘时,消息视图会缩小(降低高度),我也可以看到标题和文本输入,正如我现在打开键盘应用程序时看到的那样保持大小,但键盘将所有内容推到顶部。

【问题讨论】:

    标签: android reactjs keyboard react-native


    【解决方案1】:

    我们在https://github.com/Andr3wHur5t/react-native-keyboard-spacer 方面取得了成功。

    你可以为你的例子这样设置它:

    <View style={[{flex: 1}]}>
        <Header style={{height: 80}}/>
        <Messages style={{flex: 1}}/>
        <WriteHere style={{height: 80}}/>
    
        {/* The view that will animate to match the keyboards height */}
        <KeyboardSpacer/>
      </View>
    

    【讨论】:

    • 在什么平台上?我正在使用安卓
    猜你喜欢
    • 1970-01-01
    • 2021-05-05
    • 2020-10-05
    • 2019-02-08
    • 2023-03-22
    • 2016-05-09
    • 2018-03-25
    • 2020-05-16
    • 2020-11-23
    相关资源
    最近更新 更多