首页 > 解决方案 > @gorhom/react-native-bottom-sheet 不适用于 Android

问题描述

我一直在使用该库为我的 react native 应用程序创建底部表单模式,但它似乎不适用于 Android,但在 iOS 上却可以。我使用了文档中建议的相同背景组件和手柄组件,并且包含的​​所有内容都是提供程序,并且 SafeAreaView 我的 package.json 包括

"@gorhom/bottom-sheet": "^3.6.5", 
"react-native-reanimated": "^2.0.0",

代码结构如下:

     <BottomSheetModal ref={reference_settings}
                            index      = {1}
                            enableOverDrag={true}
                            onChange   = {(index) => { if(index === 0) { reference_settings.current.dismiss(); } }}
                            snapPoints = {[-1, '50%', '70%']}
                            backdropComponent={Backdrop}
                            handleComponent  ={(props) => (<Belt {...props} />)}
                            style            ={styles.sheet}
                        >
                        <BottomSheetView style={[styles.content]}>
                            <View style={{ width, height: '100%', overflow: 'hidden', backgroundColor: scheme === 'dark' ? '#000' : '#FFF', paddingHorizontal: 10 }}>
                              // the functions inside
                            </View>
                       </BottomSheetView>
</BottomSheetModal>

我为包含插件的 react-native-reanimated 使用了正确的 babel 配置,但它显示出来,然后我无法拖动关闭。

标签: androidiosreact-nativereact-native-reanimatedreact-native-reanimated-v2

解决方案


我知道为您回答有点晚了,但我想为其他人补充。假设您已经安装了react-native-gesture-handler,您还应该在 MainActivity.java 中添加一些代码行。

在此处输入图像描述


推荐阅读