I try to implement a navigator object. It has own stack.
My activity layout hierarchy is below:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
My fragment hierarchy is here:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragmentRootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:elevation="4dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar"
android:id="@+id/fragmentContentLayout">
</FrameLayout>
To replace fragmentA and fragmentB with animation, toolbar is animated when I use getSupportFragmentManager of activity.
But this is not fit for my requirement. Because I want each navigator to has a different stack. So, I use below code with animation(right to left)
getChildFragmentManager().beginTransaction().replace(R.id.fragmentRootLayout, fragment);
But toolbar doesn't slide right to left.