react-native – React native flatlist最后一项可见性问题

前端之家收集整理的这篇文章主要介绍了react-native – React native flatlist最后一项可见性问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在获取产品列表,然后使用平面列表显示,我的列表包含5个项目,因为您可以看到由于不同的描述文本,平面列表行高度是可变的.所以问题是我的最后一项卡片不完全可见,这可能是某种平面列表问题或布局问题.任何帮助将受到高度赞赏
  1. renderProducts() {
  2. if (this.props.loading === true) {
  3. return (
  4. <View style={Styles.spinnerStyle}>
  5. <ActivityIndicator size='large' />
  6. </View>
  7. );
  8. }
  9.  
  10. return (
  11. <FlatList
  12. data={this.props.myProducts}
  13. keyExtractor={(item) => item.id}
  14. renderItem={({ item }) => (
  15. <Card
  16. title={item.title}
  17. image={{
  18. uri: item.image !== null ? item.image.src :'../resImage.jpg'
  19. }}
  20. >
  21. <Text style={{ marginBottom: 10 }}>
  22. {item.body_html}
  23. </Text>
  24. <Button
  25. icon={{ name: 'code' }}
  26. backgroundColor='#03A9F4'
  27. fontFamily='Lato'
  28. buttonStyle={{ borderRadius: 0,marginLeft: 0,marginRight: 0,marginBottom: 0 }}
  29. title='VIEW NOW'
  30. />
  31. </Card>
  32. )}
  33. />
  34. );
  35. }
  36. render() {
  37. return (
  38. <View>
  39. <View style={Styles.viewStyle}>
  40. <Text style {Styles.textStyle}>ProductsList</Text>
  41. </View>
  42. {
  43. this.renderProducts()
  44. }
  45. </View>
  46. );
  47. }
将{flex:1}添加到包含Flatlist组件的View标记.

就我而言,

  1. const App = () => {
  2. return (
  3. <Provider store={createStore(reducers)}>
  4. <View style={{ flex: 1 }}>
  5. <Header headerText={'My App'} />
  6. <ScreenTabs /> // this is my content with FlatList
  7. </View>
  8. </Provider>
  9. );
  10. };
  11.  
  12. export default App;

猜你在找的React相关文章