react-navigation createDrawerNavigator 抽屉菜单 点击其他地方 无法关闭菜单的解决方案

react-native接入插件react-navigation 创建的抽屉菜单后  无法关闭抽屉菜单,只能再加一项“关闭”调用代码关闭菜单

点击其他地方无法关闭抽屉菜单

看了一下源码 没想到好办法后  在网上找到这样一个解决方案 现在贴出来:

下面是android的解决方案,在java中的MainActivity加入下面带+号的行代码:

import com.facebook.react.ReactActivity;
+ import com.facebook.react.ReactActivityDelegate;
+ import com.facebook.react.ReactRootView;
+ import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

public class MainActivity extends ReactActivity {

@Override
protected String getMainComponentName() {
return "Example";
}

+ @Override
+ protected ReactActivityDelegate createReactActivityDelegate() {
+ return new ReactActivityDelegate(this, getMainComponentName()) {
+ @Override
+ protected ReactRootView createRootView() {
+ return new RNGestureHandlerEnabledRootView(MainActivity.this);
+ }
+ };
+ }
}

 

引用:https://stackoverflow.com/questions/53394982/react-navigation-swipe-on-drawer-does-not-work-in-android

posted @ 2019-07-11 15:29  levenies  阅读(977)  评论(0编辑  收藏  举报