Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 支持库与设计库中的导航抽屉_Android_Navigation Drawer_Material Design_Android Support Library_Android Design Library - Fatal编程技术网

Android 支持库与设计库中的导航抽屉

Android 支持库与设计库中的导航抽屉,android,navigation-drawer,material-design,android-support-library,android-design-library,Android,Navigation Drawer,Material Design,Android Support Library,Android Design Library,如本页所述;v4支持库通过添加DrawerLayout来添加对导航抽屉的支持,设计支持库通过添加NavigationView来添加对导航抽屉的支持(作为其依赖项的DrawerLayout) 有许多教程介绍如何仅使用v4支持库创建导航抽屉,例如 既然设计支持库增加了对API级别7的支持,那么创建导航抽屉的推荐和首选方法是什么。区别在哪里?是否存在设计差异?表示应用程序的标准导航菜单,它遵循 NavigationView通常放置在抽屉布局中 当然,您可以在抽屉布局中使用自己喜欢的布局 有关导航视图的

如本页所述;v4支持库通过添加
DrawerLayout
来添加对导航抽屉的支持,设计支持库通过添加
NavigationView
来添加对导航抽屉的支持(作为其依赖项的
DrawerLayout

有许多教程介绍如何仅使用v4支持库创建导航抽屉,例如

既然设计支持库增加了对API级别7的支持,那么创建导航抽屉的推荐和首选方法是什么。区别在哪里?是否存在设计差异?

表示应用程序的标准导航菜单,它遵循

NavigationView
通常放置在
抽屉布局中

当然,您可以在
抽屉布局中使用自己喜欢的布局

有关
导航视图的详细信息

创建导航的推荐和首选方法是什么 抽屉。区别在哪里?设计上有差异吗

实际上,这些都没有什么大的区别。例如,正如
Google
doc所说:

例如,以下布局使用具有两个子项的抽屉布局 视图:包含主要内容的框架布局(由 片段),以及导航抽屉的列表视图


在本例中,我们使用了
app:menu=“@menu/drawer”
,用了一种简单易行的方法来实现这一点,在上面的代码中,他们使用了
对初学者来说非常好的问题。:)因此,设计库只是添加了
导航视图
作为附加元素,而不是
框架布局
列表视图
?仅此而已?添加
NavigationView
而不是
ListView
。您可以使用
CoordinatorLayout
,这取决于您的期望(您可以像
MaterialDesign
指南那样执行)。检查此链接以获取支持库:因此,如果我遵循材料指南,我最好使用
导航视图
,因为它已经支持它,但是如果我想构建不同的东西,我会使用自定义
框架布局
列表视图
(我必须在两种方式中使用
抽屉布局
)。
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <!-- The main content view -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <!-- The navigation drawer -->
    <ListView android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:background="#111"/>
</android.support.v4.widget.DrawerLayout>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <!--Contents like Coordinator Layout-->

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:headerLayout="@layout/header"
        app:menu="@menu/drawer" />
    <!--Here is the Drawer menu-->

</android.support.v4.widget.DrawerLayout>