112

I am trying to use FlatList (React-native) in my app. I am using it horizontally and can see the scrollbar. There is an option in ScrollView to hide the scrollbar but not in FlatList. Has anyone been able to hide it some other way. I tried using the solution of parent & child container (Hide scroll bar, but still being able to scroll) but did not work.

import React, { Component } from 'react';
import { Text, View, FlatList, StyleSheet, ScrollView } from 'react-native';
import { Card, Button } from 'react-native-elements';

const data = [
    { id: 1, title: 'title 1', details: 'details 1 details 1 details 1' },
    { id: 2, title: 'title 2', details: 'details 2 details 2 details 2 details 2 details 2 details 2' },
    { id: 3, title: 'title 3', details: 'details 3 details 3' },
    { id: 4, title: 'title 4 title 4', details: 'details 4' },
];
class CategoryRow extends Component {

    _keyExtractor = (item, index) => item.id;

    _renderItem = (item) => {
        return (
            <Card style={styles.cardContainer}>
                <Text>{item.title}</Text>   
                <Text>{item.details}</Text> 
            </Card>
        );
    }

    render() {
        return (
            <View style={{ flex: 1, overflow:'hidden' }}>
                <View style={{ overflow:'hidden' }}>
                    <Text>Category 1</Text>
                    <FlatList
                        horizontal
                        data={data}
                        renderItem={({ item }) => this._renderItem(item)}
                        keyExtractor={this._keyExtractor}

                    />
                </View>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    cardContainer: {
        width: 140,
        height: 150,
        borderWidth: 0.5,
        borderColor: 'grey',
        overflow: 'scroll',
    },
})

export default CategoryRow;
Community
  • 1
  • 1
sushil bansal
  • 1,524
  • 2
  • 10
  • 13

9 Answers9

239

Just add

showsHorizontalScrollIndicator={false}
Kawatare267
  • 3,628
  • 2
  • 15
  • 16
126

disable vertical and horizontal scroll indicator

<ScrollView
  showsVerticalScrollIndicator={false}
  showsHorizontalScrollIndicator={false}
 />
Muhammad Numan
  • 17,689
  • 4
  • 42
  • 65
28

If you are trying to hide the vertical scrollbar use this:

showsVerticalScrollIndicator={false}
ilibilibom
  • 458
  • 4
  • 9
14
FlatList is inherited from VirtualizedList.
VirtualizedList is inherited from ScrollView.
So you can use ScrollView props to hide scrollBar indicators in FlatList.

<FlatList
  ...
  showsVerticalScrollIndicator ={false}
  showsHorizontalScrollIndicator={false}
  ...
/>
gmj
  • 1,855
  • 9
  • 19
7

try this to make ListView horizontal add (horizontal={true}) mentioned below and if you just want to hide the scrollbar just add (showsHorizontalScrollIndicator={false})

<ListView showsHorizontalScrollIndicator={false}
                      horizontal={true}

/>

Atif Mukhtiar
  • 1,071
  • 8
  • 11
4

Hide vertical scroll bar

showsVerticalScrollIndicator={false}

Hide horizontal scroll bar

showsHorizontalScrollIndicator={false}

(Add theses props in your FlatList component.)

Gimnath
  • 518
  • 5
  • 11
2
<ScrollView showsVerticalScrollIndicator ={false}/>
1

In both FlatList and ScrollView you can add showsHorizontalScrollIndicator={false} prop

Rahman Haroon
  • 858
  • 2
  • 9
  • 27
0

Flatlist also provides showsHorizontalScrollIndicator and showsVerticalScrollIndicator props to handle scroll indicator. try this example:

<FlatList
                    showsHorizontalScrollIndicator={false}
                    showsVerticalScrollIndicator
                    horizontal
                    data={data}
                    renderItem={({ item }) => this._renderItem(item)}
                    keyExtractor={this._keyExtractor}
                />