【发布时间】:2018-07-29 05:39:54
【问题描述】:
我是开发 React Native 应用程序的新手。我想在一行中对齐多个(可能是三个)React Native Element 'Tile',类似于 2X3 矩阵样式。我正在尝试使用 flexbox,但无法达到结果。 这是我的代码:
import React, { Component } from 'react';
import { Text, View, TextInput, StyleSheet } from 'react-native';
import { Constants } from 'expo';
import { Tile } from 'react-native-elements';
export default class Tel extends Component {
render() {
return (
<View style={styles.tileStyle}>
<View style={{width: 20, height: 20,}}>
<Tile
featured
caption="Text"
/>
</View>
<View style={{width: 20, height: 20,}}>
<Tile
featured
caption="Some Caption Text"
/>
</View>
<View style={{width: 20, height: 20,}}>
<Tile
featured
caption="Some"
/>
</View>
<View style={{width: 20, height: 20,}}>
<Tile
featured
caption="Text"
/>
</View>
<View style={{width: 20, height: 20,}}>
<Tile
featured
caption="Some Caption Text"
/>
</View>
<View style={{width: 20, height: 20,}}>
<Tile
featured
caption="Some"
/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
tileStyle: {
flex: 1,
flexDirection: 'row',
// alignItems: 'center',
// justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
backgroundColor: '#ecf0f1',
}
});
我只能按列获得三个图块,并且没有它们的宽度或高度。 请帮忙解决。
【问题讨论】:
-
这就是你要找的东西codesandbox.io/s/j4y0pnr3p5
-
@AravindS 是这样的。但我尝试为 Tiles 使用类似的概念,但没有成功。
-
而不是
<Text>将其替换为<Tile>并查看
标签: react-native flexbox