如何在ScrollView中滚动Flatlist?

问题描述

    import React,{ useState } from "react";
    import { View,StyleSheet,FlatList,Text,ScrollView } from "react-native";
    
    import FreshHeaderBox from "../Components/Fresh Components/FreshBox";
    import FreshItemBox from "../Components/Fresh Components/FreshItemBox";
    import Updates from "../Tracks";
    import FreshGenreItems from "../Components/Fresh Components/FreshGenreItems";
    import FreshGenre from "../Components/FreshGenre";
    import Colors from "../Components/Colors";
    
    const FreshScreen = () => {
      let { album,flatlistContainer,discoverText,releaseText } = styles;
    
      return (
        <View style={styles.container}>
          <ScrollView
            style={{ flex: 1 }}
          >
            <View style={flatlistContainer}>
              <Text style={releaseText}>New Releases</Text>
              <FlatList
                nestedScrollEnabled={true}
                contentContainerStyle={{
                  alignItems: "center",}}
                horizontal={true}
                keyExtractor={FreshGenre.id}
                data={FreshGenre}
                renderItem={(item) => {
                  return (
                    <FreshGenreItems
                      genreTitle={item.item.title}
                      GenreCoverImage={item.item.coverImg}
                      style={{ width: 300 }}
                    />
                  );
                }}
              />
            </View>
            <View style={[{ ...flatlistContainer },{ height: "20%" }]}>
              <Text style={{ color: "white",fontSize: 24 }}>ALBUMS</Text>
              <FlatList
                nestedScrollEnabled={true}
                contentContainerStyle={{
                  alignItems: "center",}}
                horizontal={true}
                keyExtractor={FreshGenre.id}
                data={FreshGenre}
                renderItem={(item) => {
                  return (
                    <FreshGenreItems
                      genreTitle={item.item.title}
                      GenreCoverImage={item.item.coverImg}
                      style={{ width: 110,height: "50%" }}
                    />
                  );
                }}
              />
            </View>
            <View
              style={{
                width: "100%",}}
            >
              <Text style={discoverText}>discover</Text>
              <FlatList
                nestedScrollEnabled={true}
                keyExtractor={Updates.id}
                data={Updates}
                refreshing={true}
                renderItem={(item) => {
                  return (
                    <FreshItemBox
                      songComposer={item.item.composer}
                      title={item.item.title}
                      downloads={item.item.Downloads}
                    />
                  );
                }}
              />
            </View>
          </ScrollView>
        </View>
      );
    };
    
    const styles = StyleSheet.create({
      album: {
        width: "100%",height: "50%",},container: {
        width: "100%",height: "100%",flex: 1,paddingTop: 10,alignItems: "center",backgroundColor: Colors.primaryBackground,padding: 10,discoverText: {
        color: "white",fontSize: 25,flatlistContainer: {
        width: "100%",height: "45%",justifyContent: "center",borderRadius: 10,padding: 5,headerBox: {
        width: "100%",height: "10%",releaseText: {
        color: "white",fontSize: 30,});
    
    export default FreshScreen;

我有三个Flat-List组件,其中两个水平滚动,另一个垂直滚动。 “水平”平面列表可以滚动,但“垂直”平面列表完全不滚动。这是源代码。...

最后一个平面列表组件完全不滚动。它在滚动视图组件滚动到的任何地方结束。有什么帮助吗?我在“平面列表”子组件中启用了嵌套滚动,但仍无济于事。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)