0

현재 TabLayout을 사용하는 ViewPager가 있습니다. ViewPager의 페이지 수에 따라 TabLayout에 요소를 동적으로 추가하고 있습니다.ViewPager로 TabLayout에 DrawerLayout 추가

TabLayout 왼쪽에 버거 아이콘이있는 DrawerLayout을 추가하고 싶습니다. 이 햄버거 아이콘은 TabLayout을 스크롤 할 때 볼 수 있어야합니다.

아무런 성공없이 부모 RelativeLayout을 사용하여 TabLayout 옆에 DrawerLayout을 추가하려고했습니다.

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

답변

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> 

나 또한 여기에 같은 작업 및 작업입니다 : 여기

enter image description here

현재 XML입니다 : 여기

는 내가하고 싶은 것이있다 내가 한 일이다.