问题描述
所以这是生成图像及其大小的代码。每当我运行此代码时,图像都不会显示。 icon.png位于每个子文件夹的我的Android资源文件中,它是预安装的图像之一,因此它应该能够找到该图像并将其显示。我已尝试将完整路径放入File =“”部分,但是无论如何我都无法显示该图像?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration;
namespace PlatformBitmaps
{
public partial class MainPage : ContentPage
{
public MainPage()
{
Image image = new Image
{
Source = new FileImageSource { File = "icon.png" }
};
Label label = new Label
{
FontSize = Device.GetNamedSize(NamedSize.Medium,typeof(Label)),HorizontalOptions = Layoutoptions.Center,VerticalOptions = Layoutoptions.CenterandExpand
};
image.SizeChanged += (sender,args) =>
{
label.Text = string.Format("Rendered size = {0} x {1}",image.Width,image.Height);
};
Content = new StackLayout
{
Children =
{
image,label
}
};
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)