0

I am trying to get to scroll multiple flat-lists inside a scroll-view component. Two of the Flat-lists are horizontal and the latter scrolls vertically. The Vertical scroll is not scrolling. I found a way to use the max-Height property of the Flat-List to get it to scroll but as the max-Height value decreases, the height of the component decreases as well rendering the component in a tiny little box. Any solution to this problem?

'''

    <View style={styles.container}>
      <ScrollView style={{ flex: 1, width: "100%" }} nestedScrollEnabled={true}>
        <View style={flatlistContainer}>
          <Text style={releaseText}>New Releases</Text>
          <FlatList
            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
            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
            keyExtractor={Updates.id}
            style={{ height: "100%" }}
            maxHeight={200}
            data={Updates}
            renderItem={(item) => {
              return (
                <FreshItemBox
                  songComposer={item.item.composer}
                  title={item.item.title}
                  downloads={item.item.Downloads}
                />
              );
            }}
          />
        </View>
      </ScrollView>
    </View>
  );
};

'''

Any help with this issue?

3
  • Please check FlatList inside ScrollView doesn't scroll Commented Aug 19, 2020 at 10:28
  • @Pankaj.. My problem is different and the above method didnt work as i expected it to. The problem is when i set a maxHeight prop for the flatlist and it exceeds 400, the flatlist doesnt scroll at all and when st 100, it scrolls to the very last element but then the height of the flatlist becomes so small and hardly visible. Commented Aug 20, 2020 at 14:08
  • did you try to use section list instead? then add 2 flatlists as ListHeaderComponent and ListFooterComponent Commented Nov 27, 2020 at 16:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.