简体   繁体   English

scrollview 和 flatlist 覆盖加载视图

[英]scrollview and flatlist override loading view

I have got flatlist inside scrollview and its working fine, but both going over the loading view so I got blank view while first loading which contain both of them while first run loading.我在 scrollview 中有 flatlist 并且它工作正常,但是两者都在加载视图上,所以我在第一次加载时得到空白视图,其中在第一次运行加载时包含它们。

I didn't find any questions on it.我没有找到任何问题。

<ScrollView style={{ backgroundColor: 'white', padding: scale(5) }} contentContainerStyle={{}}
            // scrollEventThrottle={this.onScroll}
            >
                <FlatList style={{ transform: [{ scaleX: -1 }], borderBottomWidth:1, borderBottomColor: '#eee'}} contentContainerStyle={{ justifyContent: 'center', paddingBottom: !dataFollowing ? scale(40) : scale(20), alignItems: 'flex-start', backgroundColor: 'white', paddingHorizontal: scale(10) }} horizontal data={allData}
                    showsHorizontalScrollIndicator={false}
                    showsVerticalScrollIndicator={false}
                    ListHeaderComponent={
                        <TouchableOpacity onPress={() => {
                            this.props.navigation.navigate('Search');
                        }}>
</FlatList></ScrollView>

so basically I see this scrollview over loading所以基本上我看到这个滚动视图过度加载

As per i worked with this, i figured out that there is no need to use ScrollView as FlatList is Scrollable.根据我的工作,我发现不需要使用 ScrollView,因为 FlatList 是可滚动的。 If you are using FlatList inside ScrollView then it throw some warning.如果您在 ScrollView 中使用 FlatList,那么它会抛出一些警告。

This also happened same with me while using Loader with them so try: Create a state and give boolean value and in the render you would create tenrary condition (?:).这也发生在我身上,同时使用 Loader 和他们一起尝试:创建一个 state 并给出 boolean 值,在渲染中你将创建 tenrary 条件 (?:)。

For example data is coming from API, so if data is not fetched the isLoading state is true and Loader is running and as soon as data is fetched then setState isLoading to false and Flatlist data is rendering.例如数据来自 API,因此如果未获取数据,则 isLoading state 为真且加载程序正在运行,一旦获取数据,则立即将 setState isLoading 设置为 false 并呈现 Flatlist 数据。 If it doesn't clear or not matched with your question then please try to elaborate more i will help surely.如果它不清楚或与您的问题不匹配,请尝试详细说明,我一定会提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM