我在主要活动和工具栏中定义抽屉式导航,在app_bar_layout中定义TabLayout,在content_main中定义viewPager。我只需要在导航视图中的onItemListener中膨胀的一个片段中折叠的工具栏。我在片段中定义了折叠式工具栏,但应用程序被压碎了。我该怎么办?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/ReletiveLayoutStyle">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:fitsSystemWindows="true"
android:elevation="10dp"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?android:attr/actionBarSize"
android:navigationIcon="@drawable/ic_add_black_24dp"
android:titleTextColor="@color/colorAccent">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:tabGravity="fill"
app:tabIndicatorColor="@color/colorAccent"
android:layoutDirection="ltr"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/colorAccent">
<android.support.design.widget.TabItem
android:id="@+id/directTab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<android.support.design.widget.TabItem
android:id="@+id/notificationsTab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<android.support.design.widget.TabItem
android:id="@+id/devicesTab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<android.support.design.widget.TabItem
android:id="@+id/transactionTab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<android.support.design.widget.TabItem
android:id="@+id/AllPaysTab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/appBar"
/>