0

我尝试实现一个导航器对象。它有自己的堆栈。

我的活动布局层次结构如下:

<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" />

我的片段层次结构在这里:

<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>

要用动画替换 fragmentA 和 fragmentB,当我使用活动的 getSupportFragmentManager 时,工具栏是动画的。

但这不符合我的要求。因为我希望每个导航器都有不同的堆栈。所以,我使用下面的代码和动画(从右到左)

getChildFragmentManager().beginTransaction().replace(R.id.fragmentRootLayout, fragment);

但工具栏不会从右向左滑动。

4

0 回答 0