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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM