【发布时间】:2018-05-09 12:02:25
【问题描述】:
我开始学习 React Native,我正在尝试使用图像创建 3 列网格。我一直在使用 FlatList 的 numColumns 属性来指定 3 列,然后为我的图像设置 flex:1 以便它们应该填充列的空间。然而flex:1 使我的图像都没有出现,而尝试height:100,aspectRatio:1 在列中显示我的所有图像。知道这是为什么吗?我的代码如下:
export default class ArtScrollView extends React.Component {
_renderItem = (item) =>
(
<Image style={styles.art} source={{uri:item.item.imgFilePath}}/>
)
render() {
return(
<FlatList numColumns={3}
data={Object.values(this.props.pods)}
renderItem={this._renderItem}/>
);
}
}
const styles = StyleSheet.create({
art:{
height:100,
aspectRatio:1,
//flex:1, <- Having this instead of specifying the height doesn't work
marginRight:10,
}
});
【问题讨论】:
标签: react-native flexbox react-native-flatlist