9

I am using react-native-tab-view for handling tabular navigation. Is it possible to, when scrolling down, have the tab bar scroll with, but stick to the top of the screen once it reaches the top? So something like ScrollView's stickyHeaderIndices.

Here's an example of what I want, where the tab bar "Posts, Comments, About" sticks to the top.

reddit example

Michael Hsu
  • 950
  • 1
  • 9
  • 25

2 Answers2

7

It's manageable to build with react-native-tab-view, but not so trivial. This week I published a package to specifically solve this issue, it is super simple to use here is the quick start example, and below is the demo.

Dharman
  • 30,962
  • 25
  • 85
  • 135
pedrobern
  • 1,134
  • 9
  • 24
1

One of the possible solutions is this.

  1. Calculate the scroll position from the top of the tab component using onScroll callback method os ScrollView.

  2. When the contentoffset.y is zero, so just make the component absolute and make its top: 0

Siraj Alam
  • 9,217
  • 9
  • 53
  • 65