question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[v4] | Horizontal scrollView not working on Android

See original GitHub issue

Bug

I used react-native-swipper as carousel image. It’s a horizontal scrollView The scrolling only works on iOS but not on Android

Environment info

Library Version
@gorhom/bottom-sheet ^4.1.4
react-native 0.66.3
react-native-reanimated 2.2.4
react-native-gesture-handler 1.10.3

Steps To Reproduce

index.js

 <BottomSheetModalProvider>
                                <App />
</BottomSheetModalProvider>
<BottomSheetModal
                backdropComponent={renderBackdrop}
                ref={modalRef}
                index={0}
                snapPoints={snapPoints}
                handleComponent={() => <></>}
                backgroundComponent={() => <></>}
                onAnimate={(fromIndex, toIndex) => {
                    if (fromIndex === -1 && toIndex === 0) {
                        Keyboard.dismiss();
                    }
                }}
            >
                <>
                    {header}
                    <View style={styles.container}>
                        <View style={styles.wrapperSwiper}>
                            <SwiperComponent
                           >
                                {images.map((image) => (
                                   
                                ))}
                            </SwiperComponent>
                        </View>
                    </View>
                </>
            </BottomSheetModal>

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:11

github_iconTop GitHub Comments

19reactions
engee-nlcommented, Mar 18, 2022

Just wanted to toss in that using FlatList from react-native-gesture-handler fixed things in the Android emulator, but it still doesn’t work on a physical device unless you do a perfectly horizontal swipe

try adding this to the BottomSheet component, it works well for me.

activeOffsetX={[-999, 999]} activeOffsetY={[-5, 5]}

<BottomSheet name="A" ref={oBottomSheetFilterRef} index={1} snapPoints={aSnapPointsFilter} animatedPosition={oAnimatedPosition} activeOffsetX={[-999, 999]} activeOffsetY={[-5, 5]} >

So BottomSheet will only activate the gesture handler if you move more than 5 points upwards or downwards (in this case travel more than 10 points on the y axis), and it will activate when you move 999 points leftwards or rightwards (x axis). Usually you don’t move that much leftwards or rightwards on your phone, and it will thus not activate the bottom sheet handler. By not activating the bottom sheet handler (when moving leftwards or rightwards) the gesture handler will be passed down to the FlatList component.

This problem doesn’t occur on the emulator. On some physical devices where this problem occur the above code will solve it.

5reactions
ktroitskycommented, Jan 5, 2022

Update: despite scrolling after replacing the regular ScrollView with BottomSheetScrollView, it still didn’t work quite well on Android. Sometimes it scrolled fine, but sometimes the scrollable lost its offset, and snapped to the beginning of the view. Solved by importing the ScrollView from react-native-gesture-handler (similar to @AlexArendsen’s update)

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - HorizontalScrollView not working - Stack Overflow
Make HorizontalScrollView's with to "wrap_content" and maintain a single child to the HorizontalScrollView i.e.
Read more >
HorizontalScrollView - Android Developers
HorizontalScrollView only supports horizontal scrolling. For vertical scrolling ... Whether or not the auto handwriting initiation is enabled in this View.
Read more >
HorizontalScrollView cuts off part of layout if inner container ...
If HorizontalScrollView hosts a layout with items and layout declares a layout_gravity="center_horizontal" then the following behavior is noticed:
Read more >
ScrollView And Horizontal ScrollView Tutorial With Example In ...
Tutorial on Scrollview and Horizontal ScrollView teaches how views are make scrollable vertically and horizontally using examples and code in Android ...
Read more >
HorizontalScrollView in Kotlin - GeeksforGeeks
In Android ScrollView allows multiple views that are places within the parent view group to be scrolled. Scrolling in the android ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found