我已經以這種方式解決了這種複雜性:
前:
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new OloRNBridgeReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.setCurrentActivity(MenuActivity.this)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "JSMain", null);
setContentView(mReactRootView);
結果:
它使得JSMain從內容作出反應僅限本機和不包括Android Native Bottom Bar。
後:
創建Android的佈局xml文件activity_react_footer,然後加入Android UI組件要與之反應組件包括。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:punchh="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.facebook.react.ReactRootView
android:id="@+id/react_root"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.TabLayout
android:layout_weight="9"
android:id="@+id/tabLayout"
app:tabGravity="fill"
app:tabMode="fixed"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
</LinearLayout>
膨脹佈局在您的活動,然後findViewById ReactRootView負載JS組件和TabLayout也。
setContentView(R.layout.activity_react_footer);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index")
.addPackage(new MainReactPackage())
.addPackage(new OloRNBridgeReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.setCurrentActivity(MenuActivity.this)
.build();
mReactRootView = (ReactRootView) findViewById(R.id.react_root);
mReactRootView.startReactApplication(mReactInstanceManager, "JSMain", null);
tabLayout = (TabLayout) findViewById(R.id.tabLayout);
結果:
這種做法將包括來自Android的屏幕內容都和應對本土。它會完全解決你的問題。
@NimrodArgov是的,我已經遵循整合文檔。 –