Android Studio导航抽屉app:headerlayout和app:菜单XML属性?

时间:2016-06-02 04:05:39

标签: android sdk

我对Android开发完全不熟悉所以请原谅我,如果我提出愚蠢的问题,但是当我创建了一个Navigation Drawer项目时,会创建activity_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_main"
        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"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

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

我查了NavigationView课程,希望能多了解一下,但这让我感到困惑,因为我找不到XML属性 app:headerLayout app :文档中的菜单

  1. android和app命名空间有什么区别?
  2. 为什么没有记录带有应用前缀的XML属性?
  3. 我应该注意哪些隐藏的XML属性可能没有记录?如果是这样,你能提供一些参考资料吗?

1 个答案:

答案 0 :(得分:0)

NavigationView是支持库的一部分, 您要设置的布局, headerLayout或menu 将在您的包中定义, 因此,您必须在命名空间中使用命名空间,或者只使用res-auto自动查看包布局。

相关问题