react-native - FlatList Horizontal 在一行中的一列中创建两个项目
问题描述
只需要一点样式指导。我需要的是制作水平平面列表,其中第一个项目的高度应该很大,然后其他项目的列应该是 2,依此类推。
我附上了我现在拥有的和我想要的图像。
我取得了什么
我想要的是
还有我的代码
<FlatList
horizontal
data={this.state.entries}
showsHorizontalScrollIndicator={false}
contentContainerStyle={{
}}
renderItem={({ item: rowData }) => {
return (
<TouchableOpacity
key={rowData.title} onPress={() => alert(rowData.title)}>
<Card>
<CardItem cardBody>
<Image source={{ uri: rowData.ImagePath }}
style={{
height: (rowData.id == 1 ? 200 : 90),
width: (rowData.id == 1 ? 200 : 150),
flex: 1
}} />
</CardItem>
</Card>
</TouchableOpacity>
);
}}
keyExtractor={(item, index) => index.toString()}
/>
任何人都帮帮我。非常感激。
谢谢
解决方案
我希望这有帮助:
<FlatList
horizontal
data={this.state.entries}
contentContainerStyle={{ flexWrap: "wrap", flexDirection: "column" }}
renderItem={({ item: rowData }) => {
return (
<TouchableOpacity>
<Card>
<CardItem cardBody>
<View
style={{
height: rowData.id == 1 ? 200 : 90,
width: rowData.id == 1 ? 200 : 150,
borderWidth: 1,
}}
/>
</CardItem>
</Card>
</TouchableOpacity>
);
}}
/>
推荐阅读
- apache-kafka - KSQL select * from table 没有返回结果并且提示没有响应
- javascript - 箭头函数的“无法缩小此文件中的代码”
- reactjs - 在反应和取消定义中将数据从孩子传递给父母不是一个函数
- python - 烧瓶在 jsonify 中显示错误
- html - 如何在复选框列表中打破垂直线
- asp.net - 无法构建 ASP.NET Core 2.0 + Angular 2/4 - 用户注册和登录应用程序
- java - c#中的RSA加密和java中的解密数据
- angular - 检查后更改 - Angular [已选择]
- polymer - Polymer classList.add() 不更新 DOM 中的类
- java - 有没有更好的方法来使用 for 和 if-else 循环编写下面的程序?