Xamarin 嵌入式图像问题
所以,我想要的是把我的应用程序标志作为一个嵌入式png。看了好几篇教程&我觉得我真的复制了所有路径,但它仍然没有显示出明显的我做错了什么,哈哈。我现在没有任何图像,即使我在local:ImageResource aproved.Logoforappheader.png中输入时,我进入了一个proved,在那里它仍然建议它是一个源&只要我把那个句号打上在信中没有任何建议。“我的图像”作为一个跨平台应用程序,目前位于Android和iOS资源文件夹中,属性设置为EmbeddedResource 有没有人有什么想法或者能帮我找到正确的方向 下面是我的XAML代码片段:Xamarin 嵌入式图像问题,xamarin,xamarin.forms,Xamarin,Xamarin.forms,所以,我想要的是把我的应用程序标志作为一个嵌入式png。看了好几篇教程&我觉得我真的复制了所有路径,但它仍然没有显示出明显的我做错了什么,哈哈。我现在没有任何图像,即使我在local:ImageResource aproved.Logoforappheader.png中输入时,我进入了一个proved,在那里它仍然建议它是一个源&只要我把那个句号打上在信中没有任何建议。“我的图像”作为一个跨平台应用程序,目前位于Android和iOS资源文件夹中,属性设置为EmbeddedResource 有没
<?xml version="1.0" encoding="utf-8"?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:APRooved"
mc:Ignorable="d"
x:Class="APRooved.MainPage"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific; assembly=Xamarin.Forms.Core"
android:TabbedPage.ToolbarPlacement="Bottom"
BarBackgroundColor="#2B333F"
BarTextColor="#FFA600">
<ContentPage Title="Calculator" IconImageSource="Logoforappheader.png">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width ="1*" />
<ColumnDefinition Width ="1*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="2*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="3*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<BoxView Color="#2B333F"
CornerRadius="0"
Grid.Column="0"
Grid.ColumnSpan="5"
Grid.Row="0"
Grid.RowSpan="3"
WidthRequest="700"
HeightRequest="200"
VerticalOptions="Center"
HorizontalOptions="Center" />
<Image Source="{local:ImageResource APRooved.Logoforappheader.png}" WidthRequest="300" HeightRequest="100"
Grid.Column="1"
Grid.ColumnSpan="3"
Grid.Row="1"
Grid.RowSpan="1"></Image>
我的图像目前作为一个文件保存在Android和iOS资源文件夹中
跨平台应用
如果图像是正确的,则应将其放置在每个项目下的正确位置
iOS—由于iOS 9,管理和支持映像的首选方法是使用资产目录映像集,该映像集应包含支持应用程序的各种设备和比例因子所需的映像的所有版本
Android-使用Build Action:AndroidResource将图像放置在Resources/drawable目录中。还可以提供图像的高DPI和低DPI版本
通用Windows平台UWP-使用Build Action:Content将映像放置在应用程序的根目录中
然后通过以下方式加载图像:
<Image Source="xxx.jpg" />
如果图像是,则应将它们放置在共享项目中,并像您在问题中所做的那样加载它们。您不需要任何特殊代码来加载作为平台项目中嵌入资源的图像。只有当图像是共享项目的资源时,才需要这样做。请阅读以下文件:
<Image Source="xxx.jpg" />