Я хочу использовать нижнюю панель навигации в моем существующем приложении для Android, но проблема в том, что весь экран активен, можно ли загружать активность, не скрывая нижнюю панель навигации.
Пример: activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:id="@+id/myScrollingContent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Your loooooong scrolling content here. -->
</android.support.v4.widget.NestedScrollView>
<com.roughike.bottombar.BottomBar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
app:bb_tabXmlResource="@xml/bottom_bar"
app:bb_behavior="shy"/>
</android.support.design.widget.CoordinatorLayout>
это моя базовая активность,
MainActivity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BottomBar bottomBar;
bottomBar = (BottomBar) findViewById(R.id.bottomBar);
bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
@Override
public void onTabSelected(@IdRes int tabId) {
if (tabId == R.id.matching) {
Log.i("matching","matching inside "+tabId);
Intent in=new Intent(getBaseContext(),Main2Activity.class);
startActivity(in);
}else if (tabId == R.id.watchlist) {
Log.i("matching","watchlist inside "+tabId);
Intent in=new Intent(getBaseContext(),Main3Activity.class);
startActivity(in);
}
}
});
}
}
Main2Activity
public class Main2Activity extends MainActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main2);
NestedScrollView dynamicContent = (NestedScrollView) findViewById(R.id.myScrollingContent);
View wizard = getLayoutInflater().inflate(R.layout.activity_main2, null);
dynamicContent.addView(wizard);
Main3Activity
public class Main3Activity extends MainActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main3);
NestedScrollView dynamicContent = (NestedScrollView) findViewById(R.id.myScrollingContent);
View wizard = getLayoutInflater().inflate(R.layout.activity_main3, null);
dynamicContent.addView(wizard);
}
}
манифеста
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bottom.bottomnavigation">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Main2Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
<activity android:name=".Main3Activity"></activity>
</application>
</manifest>