我对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 :文档中的菜单?
答案 0 :(得分:0)
NavigationView是支持库的一部分, 您要设置的布局, headerLayout或menu 将在您的包中定义, 因此,您必须在命名空间中使用命名空间,或者只使用res-auto自动查看包布局。