即使内容不够,也会在列表底部呈现 FlatList 页脚
Render FlatList footer at the bottom of the list even if content is not enough
即使内容不足以填满整个屏幕,我也想在页面底部呈现 FlatList
的页脚。
为此,您需要查看 react-native 资源。
Here 有一个代码显示在内部添加页脚。
正如您所看到的,它包装到额外的 View
中,可以使用 ListFooterComponentStyle
属性设置样式。由于某些原因在文档中没有描述。
所以这里是解决方案:
<FlatList
data={someData}
keyExtractor={item => item.id}
contentContainerStyle={{flexGrow: 1}}
ListFooterComponentStyle={{flex:1, justifyContent: 'flex-end'}}
ListFooterComponent={<Footer/>}
...
/>
更新: 使用 AtlasRider 的评论更新答案。
即使内容不足以填满整个屏幕,我也想在页面底部呈现 FlatList
的页脚。
为此,您需要查看 react-native 资源。
Here 有一个代码显示在内部添加页脚。
正如您所看到的,它包装到额外的 View
中,可以使用 ListFooterComponentStyle
属性设置样式。由于某些原因在文档中没有描述。
所以这里是解决方案:
<FlatList
data={someData}
keyExtractor={item => item.id}
contentContainerStyle={{flexGrow: 1}}
ListFooterComponentStyle={{flex:1, justifyContent: 'flex-end'}}
ListFooterComponent={<Footer/>}
...
/>
更新: 使用 AtlasRider 的评论更新答案。