我有以下组件:带有TextInput和Button的Button。我要TextInput在顶部,Button在底部(justifyContent: 'space-between')。我是从Android本地应用程序运行这个组件的。所以我正在开发一个混合应用程序。
问题:
当我点击TextInput时,键盘就会出现,并与底部的button重叠。如果在此之后,我通过下拉方式刷新scrollView,则在键盘上显示底部的button (我想要的)。
在RefreshControl呈现之后发生了一些事情,这设置了button的正确位置。但是,我的组件看起来不太好,直到我拉起刷新它,并激活了react本机RefreshControl组件。
我的代码:
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>
);
}
}

发布于 2019-01-23 19:18:35
正如MD Naseem Ashraf在这里建议的那样,通过在我的Manifest文件android:windowSoftInputMode="adjustResize"中添加以下行来解决这个问题
发布于 2019-01-23 04:39:04
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">发布于 2019-01-23 05:30:44
将其添加到清单文件中的活动标记中。
android:windowSoftInputMode="adjustPan" https://stackoverflow.com/questions/54319420
复制相似问题