Mad*_*hur 3 javascript android reactjs react-native react-universal
嘿我想在同一行设置两个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>
Run Code Online (Sandbox Code Playgroud)
这里包括两个textInputs的CSS
inputWrap: {
borderColor: '#cccccc',
borderBottomWidth: 1,
marginBottom: 10,
},
inputdate: {
fontSize: 14,
marginBottom : -12,
color: '#6a4595',
},
inputcvv: {
fontSize: 14,
marginBottom : -12,
color: '#6a4595',
},
Run Code Online (Sandbox Code Playgroud)
请让我知道如何在同一行设置此... ..提前感谢
使用React Native,您需要使用Flexbox来布局组件.在这里查看Flexbox文档.
你想做这样的事情:
import React, { Component } from "react";
import { Text, View, StyleSheet, TextInput } from "react-native";
export default class App extends Component {
render() {
return (
<View style={styles.row}>
<View style={styles.inputWrap}>
<Text style={styles.label}>Expiration date</Text>
<TextInput style={styles.inputdate} />
</View>
<View style={styles.inputWrap}>
<Text style={styles.label}>CVV</Text>
<TextInput style={styles.inputcvv} maxLength={17} />
</View>
</View>
);
}
}
const styles = StyleSheet.create({
row: {
flex: 1,
flexDirection: "row"
},
inputWrap: {
flex: 1,
borderColor: "#cccccc",
borderBottomWidth: 1,
marginBottom: 10
},
inputdate: {
fontSize: 14,
marginBottom: -12,
color: "#6a4595"
},
inputcvv: {
fontSize: 14,
marginBottom: -12,
color: "#6a4595"
}
});
Run Code Online (Sandbox Code Playgroud)
这里最重要的部分是flexDirection: "row"在对<View style={styles.row}>元素和flex: 1对<View style={styles.inputWrap}>元素.
您可以使用Snack(Expo)编辑和运行此代码段:
https://snack.expo.io/rySUxTKuZ
| 归档时间: |
|
| 查看次数: |
9973 次 |
| 最近记录: |