React native 避免在底部的项目上使用键盘-React Native
我有一个React原生项目(带有Expo),在容器底部有两个按钮。当我打开键盘写东西时,这些东西会随着键盘一起出现。我怎样才能避免呢 这是集装箱代码->React native 避免在底部的项目上使用键盘-React Native,react-native,styles,react-native-android,react-native-ios,React Native,Styles,React Native Android,React Native Ios,我有一个React原生项目(带有Expo),在容器底部有两个按钮。当我打开键盘写东西时,这些东西会随着键盘一起出现。我怎样才能避免呢 这是集装箱代码-> render() { return ( <View style={{flex: 1}}> <Text style={styles.titulo}>Nueva Tarjeta</Text> <View style={{ flex: 1}}>
render() {
return (
<View style={{flex: 1}}>
<Text style={styles.titulo}>Nueva Tarjeta</Text>
<View style={{ flex: 1}}>
<CreditCardInput
requiresName={true}
allowScroll={true}
labels={{
name: "Nombre del titular",
number: "Número de tarjeta",
expiry: "Venc",
cvc: "CVC",
}}
cardScale={1}
labelStyle={{ fontFamily: "OpenSansRegular" }}
placeholders={{
name: "Juan Perez",
number: "1234 1234 1234 1234",
expiry: "MM/AA",
cvc: "123",
}}
onChange={this._onChange}
/>
</View>
<View style={{ flexDirection: "row", alignSelf: "center",
justifyContent: 'flex-end', marginBottom: 10}}>
<TouchableOpacity style={styles.botonVolver}>
<Text style={styles.textoVolver}>Volver</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.botonAceptar}>
<Text style={styles.textoAceptar}>Aceptar</Text>
</TouchableOpacity>
</View>
</View>
);
}
render(){
返回(
新塔热塔
玩美女人
接受器
);
}
提前谢谢 您可以尝试在Android上使用其行为道具设置为“高度”
:
const screenHeight = Dimensions.get("window").height;
export default function App() {
return (
<KeyboardAvoidingView behavior="height" style={{ flex: 1 }}>
<View style={{ height: screenHeight - 75 }}>
<Text style={styles.titulo}>Nueva Tarjeta</Text>
<CreditCardInput
requiresName={true}
allowScroll={true}
labels={{
name: "Nombre del titular",
number: "Número de tarjeta",
expiry: "Venc",
cvc: "CVC",
}}
cardScale={1}
labelStyle={{ fontFamily: "OpenSansRegular" }}
placeholders={{
name: "Juan Perez",
number: "1234 1234 1234 1234",
expiry: "MM/AA",
cvc: "123",
}}
/>
</View>
<View
style={{
flexDirection: "row",
alignSelf: "center",
justifyContent: "flex-end",
marginBottom: 10,
}}
>
<TouchableOpacity style={styles.botonVolver}>
<Text style={styles.textoVolver}>Volver</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.botonAceptar}>
<Text style={styles.textoAceptar}>Aceptar</Text>
</TouchableOpacity>
</View>
</KeyboardAvoidingView>
);
}
const screenHeight=Dimensions.get(“窗口”).height;
导出默认函数App(){
返回(
新塔热塔
玩美女人
接受器
);
}
我还使用维度
将包含信用卡输入
的视图的高度更改为基于屏幕高度,因为在该视图
上设置flex
时,转换会出现故障
确保从'react-native'
导入维度和键盘avoidingview