首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >键盘重叠底部按钮,直到刷新屏幕。

键盘重叠底部按钮,直到刷新屏幕。
EN

Stack Overflow用户
提问于 2019-01-23 02:58:00
回答 4查看 1.7K关注 0票数 0

我有以下组件:带有TextInputButtonButton。我要TextInput在顶部,Button在底部(justifyContent: 'space-between')。我是从Android本地应用程序运行这个组件的。所以我正在开发一个混合应用程序

问题:

当我点击TextInput时,键盘就会出现,并与底部的button重叠。如果在此之后,我通过下拉方式刷新scrollView,则在键盘上显示底部的button (我想要的)。

RefreshControl呈现之后发生了一些事情,这设置了button的正确位置。但是,我的组件看起来不太好,直到我拉起刷新它,并激活了react本机RefreshControl组件。

我的代码:

代码语言:javascript
运行
复制
import React, { Component } from 'react';
import { View, KeyboardAvoidingView, TextInput, RefreshControl, Button, ScrollView } from 'react-native';

export default class Authenticate extends Component {
  constructor(props) {
    super(props);
    this.state = {
      refreshing: false
    };
  }

  render() {
    return (
      <KeyboardAvoidingView enabled style={{ flex: 1 }}>
        <ScrollView
          contentContainerStyle={{ flex: 1, backgroundColor: 'gray', justifyContent: 'space-between' }}
          refreshControl={<RefreshControl refreshing={this.state.refreshing} />}>
          <View style={{ height: 200, backgroundColor: 'red' }}>
            <TextInput
              style={{
                height: 60,
                color: 'white',
                backgroundColor: 'gray',
                fontSize: 20,
                textAlign: 'center'
              }}
              value="Press Me"
            />
          </View>
          <Button style={{ backgroundColor: 'blue', width: '100%' }} title="Footer button" />
        </ScrollView>
      </KeyboardAvoidingView>
    );
  }
}

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2019-01-23 19:18:35

正如MD Naseem Ashraf在这里建议的那样,通过在我的Manifest文件android:windowSoftInputMode="adjustResize"中添加以下行来解决这个问题

票数 1
EN

Stack Overflow用户

发布于 2019-01-23 04:39:04

代码语言:javascript
运行
复制
  Try this if you want to hide button and then it won't come above keyboard.Change your  AndroidManifest.xml file.
    <activity
                    android:name=".MainActivity"
                    android:label="@string/app_name"
                    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
                    android:screenOrientation="portrait"
                    android:launchMode="singleTop"
                    android:windowSoftInputMode="adjustPan" //add this line
                    android:exported="true">
票数 0
EN

Stack Overflow用户

发布于 2019-01-23 05:30:44

将其添加到清单文件中的活动标记中。

代码语言:javascript
运行
复制
 android:windowSoftInputMode="adjustPan" 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54319420

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档