[英]How to use Framelayout with NavigationView from Support Design Library
How Can I add framelayout with the Navigation View where I am using framelayout as a container for fragments from the drawer. 如何在“导航视图”中添加框架布局,在其中将框架布局用作抽屉中碎片的容器。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar"/>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="7dp">
<android.support.design.internal.NavigationMenuView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.design.internal.NavigationMenuView>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
This is my implementation. 这是我的实现。 Is this the correct way to do it?
这是正确的方法吗?
This could be a simple implementation, you could check this post out for more information: 这可能是一个简单的实现,您可以查看这篇文章以获得更多信息:
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.NavigationView
android:id="@+id/drawer"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/header_view"
app:menu="@menu/drawer_menu" />
</android.support.v4.widget.DrawerLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.