Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permanently visible Scroll Bar for ScrollView (React Native)

Tags:

react-native

I just found that there is no permanent Scroll bar for ScrollView. I went through all the documentation and google but I don't think it actually exists.

How do we implement permanent Scroll Bar for <ScrollView>? How do we keep Scroll Bar visible?

like image 482
merry-go-round Avatar asked Oct 31 '17 15:10

merry-go-round


People also ask

How do I show the scroll bar in React Native?

Add a View component whose height is set to 100% . This will display the scroll bar with as much height as the height of its parent container.

How do you make the scrollbar only visible when overflow?

Use overflow: auto . Scrollbars will only appear when needed. (Sidenote, you can also specify for only the x, or y scrollbar: overflow-x: auto and overflow-y: auto ).

How do you keep the scroll position using Flatlist when navigating back in React Native?

In Flatlist set scrollsToTop={false} this will retain position when you navigate back from detail screen.


2 Answers

ScrollView has a prop called persistentScrollbar.

You can set the boolean to be true by adding persistentScrollbar={true} to make scrollbars visible permanently, even when they are not in use.

This only works for Android.

React Native's Official Documentation

like image 126
Simon Stroh Avatar answered Sep 25 '22 01:09

Simon Stroh


It's simple.

<ScrollView showsVerticalScrollIndicator={true} persistentScrollbar={true}></ScrollView>
like image 41
Dan Salomon Avatar answered Sep 23 '22 01:09

Dan Salomon