Xamarin图片背景未在Android设备上显示

时间:2018-10-17 12:27:40

标签: android image xaml xamarin

我尝试使用XAML和Visual Studio使用Xamarin创建应用程序示例。 例如,以下代码是InitPage.xaml。

  

<RelativeLayout>
    <Image Source="baseandroid.png" 
           RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width}"
           RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height}"/>
    <Grid RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width}"
          RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height}">

        <Label FontSize="14" Text="test" TextColor="White" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="100"
     

/>                                         

baseandroid.png可以在Android>资源> Drawable

中找到

但是我无法显示图像 enter image description here

1 个答案:

答案 0 :(得分:1)

在xaml代码中,您将在ContentPage.Content标记之外的RelativeLayout中设置Image。您必须将其放在ConetntPage.Content内。