我的主要活动布局选项卡uptil现在看起来是这样的:必须包括导航抽屉
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" >
</include>
</LinearLayout>
<FrameLayout
android:id="@+id/container_body"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</FrameLayout>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
</android.support.v4.view.ViewPager>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
<fragment
android:id="@+id/fragment_navigation_drawer"
android:name="android.mybitchinapp.com.testgui.activity.FragmentDrawer"
android:layout_width="@dimen/nav_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_navigation_drawer"
tools:layout="@layout/fragment_navigation_drawer" >
</fragment>
</android.support.v4.widget.DrawerLayout>
我需要包括TabLayout以提供选项卡的应用程序。我不知道如何包含它。我试图添加一个AppBarLayout(它将包含TabLayout),但它导致应用程序崩溃。所以它显然不是一个解决方案。我如何编辑它以使其具有TabLayout? 需要的最终产品是:
也就是说,它有碎片和Tha导航抽屉。唯一缺少的是实际的选项卡。
https://developer.android.com/reference/android/support/design/widget /TabLayout.html – Karakuri
我已经明白我需要一个TabLayout。我只想知道我应该把它放在我的布局中。直接将它放入DrawerLayout会导致应用程序崩溃。 –