I am trying to keep my top menu from scrolling with the rest of the page in my Expo React Native Web project, but after hours of troubleshooting, I can’t get the menu to be sticky. Please have a look at my current JSX setup and help me solve this issue:
<View style={{flex:1}}>
<ScrollView stickyHeaderIndices={[0]} scrollEnabled={false} style={{flex:1, flexDirection: 'column'}}>
<View style={{flexDirection: 'row', height:50, backgroundColor: 'lightgrey', alignItems: 'center', gap: 40, justifyContent: 'center'}}>
<Text style={{marginLeft: 30}}>Logo</Text>
<View style={{flex: 1}}></View>
<Text>Test</Text>
<Text>Test</Text>
<Text>Test</Text>
<Text>Test</Text>
<Text>Test</Text>
<View style={{flex: .1}}></View>
</View>
<View style={{flex:1}}>
<ScrollView nestedScrollEnabled={true} showsVerticalScrollIndicator={true} style={{backgroundColor:'red', flex: 1}}>
<View style={{backgroundColor:'green', height: 2000}}></View>
<View style={{backgroundColor:'yellow', height: 2000}}></View>
</ScrollView>
</View>
</ScrollView>
</View>
2
Answers
the solution that finally worked for me is:
You can place the Menu Bar at the top using these sets of code below,