Я создаю приложение для Android в Xamarin, и я пытаюсь использовать элемент управления NavigationView, который поставляется с библиотекой поддержки Android.Android Support Library - NavigationView
Поэтому я адаптировано мой основной макет (main.axml) как следующее:
<?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>
Как вы видите здесь, у меня есть headerLayout, что указывает на @layout/flyout_navigation_drawer
и меню, которое указывает на @menu/flyout_navigation_drawer
.
Оба файла действительно существует и код можно найти ниже:
@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>
Однако wheb я построил приложение в Xamarin я получить следующее ошибка:
Error APT0000: No resource found that matches the given name (at 'headerLayout' with value '@layout/flyout_navigation_drawer'). (APT0000)
Я включил скриншот в качестве ссылки о том, как выглядит проект: