找不到属性' headerLayout'在包中

时间:2015-08-22 13:13:16

标签: android android-layout

我正在撰写文章:http://androidgifts.com/navigation-view-using-design-support-library/#comment-11

但我收到的消息是: 错误:找不到属性' headerLayout'的资源标识符在包裹' com.thalasoft.permapp'

这是我引用的drawer_header:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="170dp"
    android:background="@color/colorPrimary"
    android:orientation="vertical" >

我引用的drawer_menu:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group android:checkableBehavior="single" >

这是我的布局:

<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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".BaseActivity"
    >
    <FrameLayout
        android:id="@+id/main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <android.support.design.widget.NavigationView
        android:id="@+id/drawer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:headerLayout="@+layout/drawer_header"
        app:menu="@+layout/drawer_menu"
        />
</android.support.v4.widget.DrawerLayout>

在阅读完一些主题后,我仍然想知道是什么让Eclipse不满意。

作为旁注,我很高兴找到布局资源&#39;引用101。

干杯,

3 个答案:

答案 0 :(得分:0)

您使用了错误的资源标识符。从+ s。

中删除 @layout

您应指定为

app:headerLayout="@layout/drawer_header"
app:menu="@layout/drawer_menu"

而不是

app:headerLayout="@+layout/drawer_header"
app:menu="@+layout/drawer_menu"

答案 1 :(得分:0)

在您的gradle中导入支持设计库

compile 'com.android.support:design:25.1.0'

答案 2 :(得分:0)

使用androidx导入材料设计设计库

implementation 'com.google.android.material:material:1.0.0-alpha3'

并且没有androidx

compile 'com.android.support:design:'
相关问题