0

Ich habe derzeit ein ViewPager ein TabLayout verwenden. Ich erstelle dynamisch Elemente zum TabLayout, basierend darauf, wie viele Seiten der ViewPager hat.hinzufügen DrawerLayout zu TabLayout mit ViewPager

Ich möchte ein DrawerLayout mit einem Burger-Symbol auf der linken Seite des TabLayout hinzufügen. Dieses Burger-Icon sollte beim Scrollen des TabLayouts sichtbar bleiben.

Ich habe versucht, das DrawerLayout neben dem TabLayout mit einem übergeordneten RelativeLayout ohne Erfolg hinzuzufügen. Hier

ist, was ich tun möchte:

enter image description here

Hier ist die aktuelle XML:

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

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <android.support.v4.widget.DrawerLayout 
       android:id="@+id/drawer_layout" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"> 

       <!-- Side navigation drawer UI --> 
       <ListView 
        android:id="@+id/navList" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_gravity="left|start" 
        android:background="#ffeeeeee"/> 

     </android.support.v4.widget.DrawerLayout> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@id/drawer_layout" 
      app:tabMaxWidth="0dp" 
      app:tabMode="fixed" 
      app:tabGravity="fill"/> 
      </RelativeLayout> 

    </android.support.design.widget.AppBarLayout> 

    ... 
    ... 
    ... 

</android.support.design.widget.CoordinatorLayout> 

Antwort

0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/lib/com.app.chasebank" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:minHeight="?attr/actionBarSize" 
     android:background="#ef453e" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/tabLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="#ef453e" 
     android:minHeight="?attr/actionBarSize" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     app:tabIndicatorColor="@android:color/white" 
     app:tabIndicatorHeight="5dp" /> 

    <android.support.v4.widget.DrawerLayout 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <android.support.v4.view.ViewPager 
      android:id="@+id/pager" 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent"/> 
     </RelativeLayout> 
     <ListView 
      android:id="@+id/listDrawer" 
      android:layout_width="240dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="right" 
      android:choiceMode="singleChoice" 
      android:background="#FF0000"/> 
    </android.support.v4.widget.DrawerLayout> 

</LinearLayout> 

ich auch auf der gleichen Aufgabe arbeite und hier ist was ich getan habe.

Verwandte Themen