Hide scrollbar in FlatList (React Native) in Android

React NativeReact Native-Flatlist

React Native Problem Overview


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 (https://stackoverflow.com/questions/16670931/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;

React Native Solutions


Solution 1 - React Native

Just add

showsHorizontalScrollIndicator={false}

Solution 2 - React Native

disable vertical and horizontal scroll indicator

<ScrollView
  showsVerticalScrollIndicator={false}
  showsHorizontalScrollIndicator={false}
 />

Solution 3 - React Native

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

showsVerticalScrollIndicator={false}

Solution 4 - React Native

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}
  ...
/>

Solution 5 - React Native

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}

/>

Solution 6 - React Native

Hide vertical scroll bar

showsVerticalScrollIndicator={false}

Hide horizontal scroll bar

showsHorizontalScrollIndicator={false}

(Add theses props in your FlatList component.)

Solution 7 - React Native

<ScrollView showsVerticalScrollIndicator ={false}/>

Solution 8 - React Native

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

Solution 9 - React Native

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}
                />

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionsushil bansalView Question on Stackoverflow
Solution 1 - React NativeKawatare267View Answer on Stackoverflow
Solution 2 - React NativeMuhammad NumanView Answer on Stackoverflow
Solution 3 - React NativeilibilibomView Answer on Stackoverflow
Solution 4 - React NativegmjView Answer on Stackoverflow
Solution 5 - React NativeAtif MukhtiarView Answer on Stackoverflow
Solution 6 - React NativeGimnathView Answer on Stackoverflow
Solution 7 - React Nativewahyu setiawanView Answer on Stackoverflow
Solution 8 - React NativeRahman HaroonView Answer on Stackoverflow
Solution 9 - React NativeMUKESH BUWADEView Answer on Stackoverflow