我在stackoverflow上尝试了很多答案,但无法解决棉花糖设备的导航抽屉问题。 This is the screenshot here.
在预棉花糖设备上,使用此系列解决了这个问题。
ERROR
我需要帮助。我有四个由Android Studio生成的文件
activity_main.xml中
android:layout_marginTop="@dimen/abc_action_bar_default_height_material"
content_main.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">
<include
layout="@layout/app_bar_deal_screen"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<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"
android:layout_marginTop="@dimen/abc_action_bar_default_height_material"
app:headerLayout="@layout/nav_header_deal_screen"
app:menu="@menu/activity_deal_screen_drawer" />
</android.support.v4.widget.DrawerLayout>
app_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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/content_deal_screen"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.immacbytes.foodyum.dealScreen"
tools:showIn="@layout/app_bar_deal_screen">
</android.support.constraint.ConstraintLayout>
nav_header_main.xml
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.immacbytes.foodyum.dealScreen">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppHomeScreen.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/AppHomeScreen.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_deal_screen" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
答案 0 :(得分:1)
这可行但是当你在api下面运行它&lt; 20它保留了一些空间,这是我的问题如何解决这个问题
android:layout_marginTop="80dp"
答案 1 :(得分:0)
尝试添加
app:layout_behavior="@string/appbar_scrolling_view_behavior"
到您的NavigationView。