【发布时间】:2017-08-23 14:15:11
【问题描述】:
我目前有一个使用 TabLayout 的 ViewPager。我根据 ViewPager 的页面数动态地将元素添加到 TabLayout。
我想在 TabLayout 的左侧添加一个带有汉堡图标的 DrawerLayout。滚动 TabLayout 时,此汉堡图标应保持可见。
我尝试使用父级 RelativeLayout 在 TabLayout 旁边添加 DrawerLayout,但没有成功。
这是我想做的:
这是当前的 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>
【问题讨论】:
标签: android android-viewpager android-tablayout drawerlayout navigation-drawer