Xamarin.Forms PCL无法显示图像

时间:2017-08-08 15:51:07

标签: image xamarin xamarin.forms

我正在学习Xamarin.Forms PCL。我想在页面上加载图像,我试图用uri加载图像,这没关系。但是我将图像添加到项目中,它不起作用。

<StackLayout Margin="0,20,0,0">
        <Image x:Name="img" Source="mario.jpg"/>
        <Button x:Name="btnRotate" Clicked="btnRotate_Clicked" Text="Rotate" />
    </StackLayout>

enter image description here

感谢任何帮助。谢谢!

1 个答案:

答案 0 :(得分:2)

  

对于Android兼容性,您无法在图片名称中包含短划线或空格

将您的图片从piotr-chrobot-276746.jpg重命名为其他内容,例如 piotrchrobot.jpg

enter image description here

  

https://developer.xamarin.com/guides/android/application_fundamentals/resources_in_android/part_1_-_android_resource_basics/

不要忘记将构建操作设置为 AndroidResource。

enter image description here