小编Ale*_*lov的帖子

如何在Android react-native上避免键盘推送布局

我将面临这个问题几个月,我仍然无法解决它.我在视图的底部有一个文本输入,一旦点击,它就会被软键盘抬起.相反,整个布局被推高,你无法看到它的上半部分.

我尝试了许多不同的键盘间隔库,但它们都只是将TextInput推得更高..

截图: 没有键盘 带键盘

这是我的主要观点:

<View
    style={{
      flex: 1,
      alignItems: 'stretch',
      justifyContent: 'space-between',
      overflow: 'hidden',
      backgroundColor: Colors.darkBlue
    }}
  >
    {/* Header */}
    <View
      style={{
        flexDirection: 'row',
        alignItems: 'stretch',
        height: 300
      }}>
      {/* Question bubble */}
      { (this.state.question && this.state.question !== '') ? (
          <TouchableOpacity
            style={{
                flex: 1,
                flexDirection: 'row',
                backgroundColor: 'transparent',
                alignItems: 'stretch',
                paddingRight: QUESTION_SPEAKER_RADIUS
              }}
          >
            <View
              style={{
                  flex: 1,
                  alignSelf: 'stretch',
                  alignItems: 'center',
                  justifyContent: 'center',
                  backgroundColor: 'white',
                }}
            >
              <Text>
                {this.state.question}
              </Text>
            </View>
          </TouchableOpacity>
        ) : null …
Run Code Online (Sandbox Code Playgroud)

keyboard android react-native

14
推荐指数
5
解决办法
2万
查看次数

标签 统计

android ×1

keyboard ×1

react-native ×1