我的Xamarin Android项目在Resources
下没有Drawable
文件夹,我有mipmap
文件夹。我正在尝试为共享项目中的工具栏项设置图标。如果我将图像设置为嵌入资源,则应该能够从共享项目中访问它,我错了吗?
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BoringAppUi.MainPage" Title="Main Page">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Logout" Clicked="OnLogoutButtonClicked" Order="Primary" Priority="0"/>
<ToolbarItem Text="Home" Icon="@mipmap/baseline_home_blue_48.png" Clicked="OnHomeIconClicked" Order="Primary" Priority="1"/>
</ContentPage.ToolbarItems>
<ContentPage.Content>
<StackLayout>
<Label Text="Main app content goes here" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
我也尝试过从后台代码中进行设置。
var toolbarItemHome = new ToolbarItem
{
Text = "Home",
Icon = "@mipmap/baseline_home_blue_48.png"
};
toolbarItemHome.Clicked += OnHomeIconClicked;
ToolbarItems.Add(toolbarItemHome);