嘿,我想在同一行设置两个 textInputs,在 Android 模拟器中命名为 Expiration date 和 CVV。
<View style={{flex: 1, flexDirection: 'row'}}>
<Text style={styles.label}style= {{width : 100}}>Expiration date</Text>
<View style={styles.inputWrap}>
<TextInput style={styles.inputdate} />
</View>
<Text style={styles.label}>CVV</Text>
<View style={styles.inputWrap}>
<TextInput style={styles.inputcvv } maxLength={17} />
</View>
这里包括两个 textInputs 的 CSS
inputWrap: {
borderColor: '#cccccc',
borderBottomWidth: 1,
marginBottom: 10,
},
inputdate: {
fontSize: 14,
marginBottom : -12,
color: '#6a4595',
},
inputcvv: {
fontSize: 14,
marginBottom : -12,
color: '#6a4595',
},
请让我知道如何在同一行上设置它。提前致谢
原文由 Madhur 发布,翻译遵循 CC BY-SA 4.0 许可协议
使用 React Native,你需要使用 Flexbox 来布置你的组件。 在此处查看 Flexbox 文档。
你想做这样的事情:
The important part here is the
flexDirection: "row"
on the<View style={styles.row}>
element and theflex: 1
on the<View style={styles.inputWrap}>
elements.您可以使用 Snack (Expo) 编辑和运行此代码段:
https://snack.expo.io/rySUxTKuZ