gpt4 book ai didi

javascript - 如何防止键盘将覆盖 View 向上推?

转载 作者:行者123 更新时间:2023-12-04 14:17:09 27 4
gpt4 key购买 nike

我不希望键盘在键入时将 View 向上推。键盘有足够的空间不会插入覆盖层,但它仍在这样做。我试过在叠加层内外使用 keyboardavoidingview 定位和填充,但没有成功。

  render() {
return (
<Overlay
isVisible={this.state.isVisible}
width="auto"
height="auto"
overlayStyle={{ width: "90%", height: "50%", marginBottom: "70%" }}
>
<View>
<Text>Schedule</Text>
<TextInput
label="Event"
style={{ width: "95%", margin: "3%" }}
theme={{ colors: { primary: Themes.primaryTheme } }}
/>
<TextInput
label="Date & Time"
style={{ width: "95%", margin: "3%" }}
theme={{ colors: { primary: Themes.primaryTheme } }}
/>
<TextInput
label="Location"
style={{ width: "95%", margin: "3%" }}
theme={{ colors: { primary: Themes.primaryTheme } }}
/>
<View style={{ flexDirection: "row" }}>
<Button
mode="text"
style={{ width: "40%", margin: "3%" }}
onPress={() => this.setState({ isVisible: false })}
>
Cancel
</Button>
<Button
mode="contained"
style={{ width: "40%", margin: "3%" }}
onPress={() => this.setState({ isVisible: false })}
>
Create
</Button>
</View>
</View>
</Overlay>
);
}

最佳答案

我对这个问题的解决方案:

import React , {Component} from 'react';
import {View , Dimensions,ScrollView} from 'react-native';

const windowHeight = Dimensions.get('window').height;

export default class Items extends Component {
render(){
return(
<View style={{flex:1}}>
<ScrollView style={{flex:1}}>
<View style={{width:'100%', height:windowHeight }}>
/*Every thing inside this will shift up with out changing style */
</View>
</ScrollView>
</View>
)
}
}

关于javascript - 如何防止键盘将覆盖 View 向上推?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59122488/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com