我想在我的應用程序中導航抽屜,但我不想讓導航抽屜蓋住我的操作欄。操作欄應始終可見。我搜索互聯網,並從stackoverflow和一些博客得到了一些解決方案,但都是一樣的。我提到這個解決方案Using Navigation Drawer without TitleBar or ActionBar,但仍然是相同的。正如他們在答案中提到的,我先給android.support.v7.widget.Toolbar
然後android.support.design.widget.NavigationView
。 Android工作室設計預覽顯示正確,但實時手機操作欄由導航抽屜覆蓋。導航抽屜蓋操作欄
在Android Studio中
手機
這裏是activity_album_dashboard.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activity.AlbumDashboardActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_album_dashboard" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/nav_header_album_dashboard"
app:menu="@menu/activity_album_dashboard_drawer" />
</android.support.v4.widget.DrawerLayout>
和nav_header_album_dashboard.xml(我不想頭,所以就一直空的LinearLayout)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
</LinearLayout>
設置您的導航視圖,添加layout_below:工具欄 –
檢查我的答案我更新了你的XML。只需將其複製並粘貼到佈局文件中 –
從抽屜佈局中刪除此行android:fitsSystemWindows =「true」 –