[英]Mac Xamarin.Forms shows image on iOS simulator but not Android simulator
I am using a MacBook Pro that does not have hardward acceleration for graphics, so maybe that's the whole problem, but I hope not. 我正在使用没有图形加速功能的MacBook Pro,所以也许这就是整个问题,但我希望不会。
When I use VisualStudio to run a Xamarin.Forms app on the iPhone simulator, it works fine. 当我使用VisualStudio在iPhone模拟器上运行Xamarin.Forms应用程序时,它运行良好。
When I run it on the Android simulator (right now the Pixel, but it's the same for all of them), it works OK but none of the images show up. 当我在Android模拟器(现在是Pixel,但所有像素都相同)上运行它时,它工作正常,但没有图像出现。
How can I get the images to show up on Android? 如何将图像显示在Android上?
Here's an example of code where it happens (you'll have to change the image path for it to work): 这是发生代码的示例(您必须更改图像路径才能工作):
<?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="UdemyHelloWorldOne.AbsoluteLayoutExercise2">
<AbsoluteLayout>
<Image Source="/Users/jesseonbookofe/Documents/Xamarin/UdemyHelloWorldOne/UdemyHelloWorldOne/absolutelayoutexercise2-image-flower.jpg"
Aspect="AspectFill" AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
AbsoluteLayout.LayoutFlags="All" />
<Label Text="Relax" FontSize="30" TextColor="White"
AbsoluteLayout.LayoutFlags="SizeProportional, XProportional"
AbsoluteLayout.LayoutBounds="0.5,20,1,0.1"
HorizontalOptions="Center"/>
<BoxView BackgroundColor="Black" Opacity="0.5"
AbsoluteLayout.LayoutFlags="PositionProportional, WidthProportional"
AbsoluteLayout.LayoutBounds="0,1,1,100"/>
<StackLayout AbsoluteLayout.LayoutBounds="0,1,1,100" Padding="30,0"
Orientation="Horizontal" VerticalOptions="Center"
AbsoluteLayout.LayoutFlags="PositionProportional, WidthProportional">
<Label Text="Profile" FontSize="15" TextColor="White"/>
<Label Text="Meditate" FontSize="15" TextColor="White"
HorizontalOptions="CenterAndExpand"/>
<Label Text="Themes" FontSize="15" TextColor="White"/>
</StackLayout>
</AbsoluteLayout>
</ContentPage>
如果图片名称包含连字符,则Xamarin android和iOS不支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.