Tablayout 旁边的导航抽屉按钮
Navigation Drawer Button next to Tablayout
我想要一个如下图所示的 Appbar
/Toolbar
。
我不需要帮助来设置 Tablayout
工作 - 我知道 -
但我对设置 Appbars
/Toolbars
不是很有经验。
DrawerLayout
对我来说应该不是问题。
我已经有了下面的代码,但我不知道如何继续。
<android.support.design.widget.CoordinatorLayout
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/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tabs">
//here are my tabItems
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/menu_nav"
app:headerLayout="@layout/nav_header"/>
</android.support.v4.widget.DrawerLayout>
</android.support.design.widget.CoordinatorLayout>
正如 Mike M. 所说,您必须在 TabLayout
周围放置一个 Toolbar
。
然后您必须在 activity 中执行以下操作:
首先用 setSupportActionBar()
将工具栏设置为 ActionBar。
然后使用 getActionBar()
获取 ActionBar 并使用 Vector Asset menu
调用 setHomeAsUpIndicator()
。
我想要一个如下图所示的 Appbar
/Toolbar
。
我不需要帮助来设置 Tablayout
工作 - 我知道 -
但我对设置 Appbars
/Toolbars
不是很有经验。
DrawerLayout
对我来说应该不是问题。
我已经有了下面的代码,但我不知道如何继续。
<android.support.design.widget.CoordinatorLayout
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/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tabs">
//here are my tabItems
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/menu_nav"
app:headerLayout="@layout/nav_header"/>
</android.support.v4.widget.DrawerLayout>
</android.support.design.widget.CoordinatorLayout>
正如 Mike M. 所说,您必须在 TabLayout
周围放置一个 Toolbar
。
然后您必须在 activity 中执行以下操作:
首先用 setSupportActionBar()
将工具栏设置为 ActionBar。
然后使用 getActionBar()
获取 ActionBar 并使用 Vector Asset menu
调用 setHomeAsUpIndicator()
。