简体   繁体   English

如何通过支持设计库中的NavigationView使用Framelayout

[英]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.

相关问题 使用Android设计支持库中的NavigationView - Using NavigationView from Android Design Support Library 如何设计Design Support库的NavigationView样式? - How to style the Design Support library's NavigationView? 如何从设计支持库以编程方式访问位于 NavigationView 标头内的微调器? - How do I programatically access a spinner located inside the header of the NavigationView from the design support library? 如何在设计支持库的navigationView中编辑项目的大小? - How to edit size of an item in navigationView of the design support library? 如何将页脚添加到 NavigationView - Android 支持设计库? - How to add footer to NavigationView - Android support design library? Android设计支持库:NavigationView源代码 - Android Design Support Library: NavigationView source code 如何在 Android 设计库中的 NavigationView 上放置计数器? - How to put counter on NavigationView from Android Design Library? 自定义NavigationView-添加动态headerView,Android支持设计库 - Customising NavigationView - Adding dynamic headerView, Android Support Design Library 如何设计从右到左android.support.design.widget.NavigationView? - How to design right to left android.support.design.widget.NavigationView? Android支持库-NavigationView - Android Support Library - NavigationView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM