首页 > 解决方案 > 找不到与给定名称匹配的资源(在“菜单”中,值为“@menu/bottomnavigationmain”)

问题描述

我正在尝试进行按钮导航,并且正在关注本教程。https://blog.xamarin.com/exploring-androids-bottom-navigation-view/。这是我在 axml 文件中的代码: file: ly_homescreen.axml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:background="@color/colorPrimaryDark"
    android:minWidth="25px"
    android:minHeight="25px"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/linearLayout1">
        <ImageView
            android:src="@drawable/logo"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:layout_margin="5dp"
            android:id="@+id/imageView1" />
        <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/bottom_navigation" />
        <android.support.design.widget.BottomNavigationView
            android:id="@+id/bottom_navigation"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:layout_gravity="start"
            android:layout_alignParentBottom="true"
            android:background="@android:color/white"
            app:elevation="16dp"
            app:menu="@menu/bottomnavigationmain" />
    </LinearLayout>
</RelativeLayout>

这是我在bottomnavigationmain.xml文件中的代码,位于projectname>menu>bottomnavigationmain.xml. 我收到了我在标题中提到的错误。任何帮助表示赞赏。

如果这很重要,我会在bottomnavigationmain.xml文件中收到错误消息:

 @(Content) build action is not supported.

标签: xmlvisual-studioxamarinvisual-studio-2015xamarin.android

解决方案


打开bottomnavigationmain.xml的属性,将BuildAction从Content改为AndroidResource


推荐阅读