【发布时间】:2022-01-20 13:41:18
【问题描述】:
我把crypto.png图片放到Android项目Resources下的drawable文件夹中。
在我右键单击图像后 -> 构建操作 -> 嵌入式资源。
在主项目的MainPage.xaml 中,我尝试像这样加载图像:
<Image x:Name="HeadImage"
WidthRequest="100"
HeightRequest="100"
MinimumHeightRequest="100"
MinimumWidthRequest="100"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"
Aspect="AspectFit"
Source="crypto.png"/>
但图片无法加载。
我在 c# 代码中尝试了这样的第二种方法:
var HeadImage = new Image { Aspect = Aspect.AspectFit };
HeadImage.Source = ImageSource.FromFile("crypto.png");
这个方法又没用了..
【问题讨论】:
-
你能举个例子吗,我会接受你的回答
-
我尝试使用: HeadImage = new Image { Source = ImageSource.FromResource("crypto.png") };蚂蚁这对我来说不再有用了