【问题标题】:React Native Keyboard covers TextInput KeyboardAvoidingView on AndroidReact Native Keyboard 涵盖了 Android 上的 TextInput KeyboardAvoidingView
【发布时间】:2021-06-13 21:52:16
【问题描述】:

我想为聊天应用创建一个 TextInput。在 Ios 上一切正常,但在 Android 上,如果打开键盘,TextInput 会被覆盖:

它应该看起来和 Ios 上的一样:

我的代码如下所示:

<KeyboardAvoidingView enabled behavior={Platform.OS == 'ios' ? 'padding' : null} keyboardVerticalOffset={Platform.OS == 'ios' ? null : 90} style={{felx: 1, width: "100%", flexDirection: "row", alignItems: "center", marginVertical: 5, justifyContent: "center" }}>
          <TouchableOpacity>
            ...
          </TouchableOpacity>
          <TextInput style={{
            height: 47,
            width: "80%",
            backgroundColor: "#fff",
            paddingHorizontal: 10,
            borderRadius: 14,
            color: "grey",
            fontSize: 17,
          }}
          editable={this.state.inputdisabled}
          placeholder={"Nachricht..."}
          value={nachricht}
          blur={true}
          blurOnSubmit={false}
          multiline
          clearButtonMode='always'
          onChangeText={text => this.setState({nachricht: text})}
          />
          <TouchableOpacity>
            ..
          </TouchableOpacity>
        </KeyboardAvoidingView>

【问题讨论】:

    标签: android react-native keyboard expo


    【解决方案1】:

    在将 expo 应用程序执行到裸工作流后,一切看起来都很好。

    【讨论】:

      【解决方案2】:

      代码看起来不错,您可以将 KeyboardAvoidingView 主体内的内容包装在视图中,并在视图内移动您的样式

      【讨论】:

        猜你喜欢
        • 2020-08-27
        • 2017-10-06
        • 1970-01-01
        • 2019-07-01
        • 2019-04-02
        • 1970-01-01
        • 2022-01-10
        • 1970-01-01
        • 2019-10-13
        相关资源
        最近更新 更多