我刚刚开始使用React Native,我正在使用RN开发一个应用程序......我有点卡在这里...我在应用程序的一个组件中有一个表单,其中有几个TextInputs并排排列,如图像中所示下面
这是我试图实现上述设计的代码.
import React, {Component} from 'react';
import {View, Text, StyleSheet, TextInput, TouchableHighlight} from 'react-native';
export default class AddItems extends Component {
onAdd() {
alert('Hello');
}
render() {
return (
<View style={addItemStyles.wrapper}>
<View>
<Text>Item to give cash credit for:</Text>
<View>
<View>
<TextInput placeholder="Test" style={{justifyContent: 'flex-start',}} />
</View>
<View>
<TextInput placeholder="Test" style={{justifyContent: 'flex-end',}} />
</View>
</View>
</View>
</View>
);
}
}
const addItemStyles = StyleSheet.create({
wrapper: {
padding: 10,
backgroundColor: '#FFFFFF'
},
inputLabels: {
fontSize: 16,
color: '#000000',
marginBottom: 7,
},
inputField: {
backgroundColor: '#EEEEEE',
padding: 10,
color: '#505050',
height: 50
},
inputWrapper: {
paddingBottom: 20,
},
saveBtn: {
backgroundColor: '#003E7D',
alignItems: 'center',
padding: 12,
},
saveBtnText: {
color: '#FFFFFF',
fontSize: 18,
}
});
Run Code Online (Sandbox Code Playgroud)
但相反,我得到了这样的观点.
我知道这可能是一个小问题,但正如我上面所说,我刚开始使用React Native,所以你可以把我当作菜鸟......提前感谢你的帮助.期待您的回答.
yan*_*029 20
在风格中使用"flexDirection"
render() {
return (
<View style={addItemStyles.wrapper}>
<View>
<Text>Item to give cash credit for:</Text>
<View style={{flexDirection:"row"}}>
<View style={{flex:1}}>
<TextInput placeholder="Test" style={{justifyContent: 'flex-start',}} />
</View>
<View style={{flex:1}}>
<TextInput placeholder="Test" style={{justifyContent: 'flex-end',}} />
</View>
</View>
</View>
</View>
);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10196 次 |
| 最近记录: |