【发布时间】:2016-10-05 19:02:25
【问题描述】:
我的问题可能很容易解决,但不幸的是我无法解决这个问题。我已经使用 Android Studio 提供的 NavigationDrawer 设置了一个。我的问题是,如果不使 NavigationDrawer 无法使用,我就无法在 appbar 下放置 FrameLayout。我尝试了几种方法,例如使用线性布局或尝试使用 android:layout_below 的相对布局。但是每次我做这些事情时,用NavigationDrawer 切换FrameView 中的片段就不再起作用了。
我的 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">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/appbar"
layout="@layout/app_bar_main_map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<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/activity_main_map_drawer" />
</android.support.v4.widget.DrawerLayout>
如果您需要更多代码,我会尽快发布。
非常感谢每一个帮助。
【问题讨论】:
标签: android xml navigation-drawer android-appbarlayout android-framelayout