react-native - 如何在本机反应中使我的 Flatlist 项目全高?
问题描述
我在 FlatList 中有 5 个项目。
我希望我的项目在全屏中均匀呈现(顶部图像到底部图像)。
如果我改变高度或弹性,它将在当前背景图像空间中显示 5 个项目。
我应该改变什么..?
<View
style={{
flex: 1,
flexDirection: 'column',
backgroundColor: 'black',
}}
>
<FlatList
style={{ flex: 1 }}
data={emotions}
renderItem={({ item }) => (
<ImageBackground
source={item.img}
style={{
width: '100%',
height: '100%',
justifyContent: 'center',
margin: 2,
alignContent: 'stretch',
}}
>
<Text
style={{
fontSize: 20,
textAlign: 'center',
color: 'white',
}}
onPress={() => this.handlePress(`${item.title}`)}
>
{item.title}
</Text>
</ImageBackground>
)}
keyExtractor={item => item.title}
numColumns={1}
></FlatList>
</View>
解决方案
在渲染项目中你可以试试这个
请更换这个
height: '100%'
和
flex:1
推荐阅读
- r - kable/kableExtra 的常规输出样式
- d3.js - 为什么减去边距只在设置 svg 宽度时将它们添加回来
- ruby - $PATH 中的非 UTF8 字符会干扰 Homebrew Mac
- node.js - client.guilds.get 不是函数 DISCORD.JS
- flutter - 滚动视图内带有扩展小部件的颤振列
- azure - 无法在 Slack 中向机器人发送 DM。Bot 是使用 azure botframework 创建的,并使用了渠道集成
- pyinstaller - 微软后卫停止 pyinstaller
- android - Flutter 创建父目录失败
- arrays - 打印数组但突出显示特定值 {emu8086}
- microsoft-graph-api - 使用 curl 的 msgraph 客户端断言证书,如何生成断言