加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 20:43:48 所属栏目:百科 来源:网络整理
导读:我正在获取产品列表,然后使用平面列表显示,我的列表包含5个项目,因为您可以看到由于不同的描述文本,平面列表行高度是可变的.所以问题是我的最后一项卡片不完全可见,这可能是某种平面列表问题或布局问题.任何帮助将受到高度赞赏 renderProducts() { if (this.
我正在获取产品列表,然后使用平面列表显示,我的列表包含5个项目,因为您可以看到由于不同的描述文本,平面列表行高度是可变的.所以问题是我的最后一项卡片不完全可见,这可能是某种平面列表问题或布局问题.任何帮助将受到高度赞赏
renderProducts() {
        if (this.props.loading === true) {
            return (
                <View style={Styles.spinnerStyle}>
                    <ActivityIndicator size='large' />
                </View>
            );
        }

        return (
                <FlatList
                    data={this.props.myProducts}
                    keyExtractor={(item) => item.id}
                    renderItem={({ item }) => (
                        <Card 
                            title={item.title} 
                            image={{ 
                                uri: item.image !== null ? item.image.src :'../resImage.jpg' 
                            }}
                        >
                            <Text style={{ marginBottom: 10 }}>
                                {item.body_html}
                            </Text>
                            <Button
                                icon={{ name: 'code' }}
                                backgroundColor='#03A9F4'
                                fontFamily='Lato'
                                buttonStyle={{ borderRadius: 0,marginLeft: 0,marginRight: 0,marginBottom: 0 }}
                                title='VIEW NOW' 
                            />
                      </Card>
                      )}
                />
        );
    }
    
    render() {
        return (
            <View>
                <View style={Styles.viewStyle}>
                    <Text style    {Styles.textStyle}>ProductsList</Text>
                </View>
                    { 
                        this.renderProducts() 
                    }
            </View>
        );
    }
将{flex:1}添加到包含Flatlist组件的View标记.

就我而言,

const App = () => {
  return (
    <Provider store={createStore(reducers)}>
    <View style={{ flex: 1 }}>
      <Header headerText={'My App'} />
      <ScreenTabs /> // this is my content with FlatList 
    </View>
    </Provider>
  );
};

export default App;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读