Complexity
Complexity

Reputation: 5820

Android Support Library - NavigationView

I'm building an Android Application in Xamarin and I'm trying to use the NavigationView control that comes with the Android Support Library.

Therefore, I've adapted my main layout (main.axml) like the following:

<?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"
        android:id="@+id/DrawerLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

    <!-- Renders the toolbar on the button. -->
        <include
            layout="@layout/Toolbar" />

    </LinearLayout>

    <!-- Android Navigation Drawer. -->
        <android.support.design.widget.NavigationView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:id="@+id/navigationView"
            app:headerLayout="@layout/flyout_navigation_drawer"
            app:menu="@menu/flyout_navigation_drawer"/>

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

As you see here, I have an headerLayout that points to @layout/flyout_navigation_drawer and a menu that points to @menu/flyout_navigation_drawer.

Both files does exists and the code can be found below:

@layout/flyout_navigation_header

<?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="150dp"
    android:orientation="vertical">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/nav_header_bg"
        android:scaleType="centerCrop" />
    <TextView
        style="@style/TextAppearance.AppCompat.Subhead"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_margin="16dp"
        android:text="Your Name Here"
        android:textColor="@android:color/white" />
</FrameLayout>

@menu/flyout_navigation_drawer

<?xml version="1.0" encoding="UTF-8" ?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group android:checkableBehavior="single">
        <item
            android:id="@+id/navigation_item_1"
            android:checked="true"
            android:title="Item One" />
        <item
            android:id="@+id/navigation_item_2"
            android:title="Item Two" />
    </group>
</menu>

However, wheb I built the app in Xamarin I do receive the following error:

Error APT0000: No resource found that matches the given name (at 'headerLayout' with value '@layout/flyout_navigation_drawer'). (APT0000)

I've included a screenshot as a reference on how the project looks:

enter image description here

Upvotes: 0

Views: 1613

Answers (1)

JoeyJubb
JoeyJubb

Reputation: 2321

It's just a typo. Your file is named "flyout_navigation_header" but you've got:

        app:headerLayout="@layout/flyout_navigation_drawer"

Upvotes: 1

Related Questions