[英]React Native Keyboard covers TextInput KeyboardAvoidingView on Android
我想為聊天應用程序創建一個 TextInput。 在 Ios 上一切正常,但在 Android 上,如果打開鍵盤,則會覆蓋 TextInput:
我的代碼如下所示:
<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>
在將 expo 應用程序執行到裸工作流后,一切看起來都很好。
代碼看起來不錯,您可以將 KeyboardAvoidingView 主體內的內容包裝在視圖中,並在視圖內移動您的樣式
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.