如何在一个活动中也有一个侧面导航抽屉在Android中的选项卡?

问题描述:

我有一个侧面导航栏的活动。现在我想在同一活动中添加选项卡。如何添加标签连同侧面导航抽屉如何在一个活动中也有一个侧面导航抽屉在Android中的选项卡?

+0

使用[TabLayout(https://developer.android.com/reference/android/support/design/widget/TabLayout.html) 。 –

创建另一个xml文件并将其添加为acitivty_viewpager。

<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.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 


     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/orange" 

      app:tabMode="scrollable" /> 
    </android.support.design.widget.AppBarLayout> 


    <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.design.widget.CoordinatorLayout> 

,包括您在本活动文件中像

<include layout="@layout/acitivty_viewpager"/>