【问题标题】:Xamarin Image background Not Showing on AndroidXamarin 图像背景未在 Android 上显示
【发布时间】:2018-10-17 20:41:58
【问题描述】:

我尝试使用 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 > Ressources > Drawable 中找到

但我无法显示图片 enter image description here

【问题讨论】:

标签: android image xaml xamarin


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-15
    • 1970-01-01
    • 1970-01-01
    • 2015-07-02
    • 1970-01-01
    • 2020-12-16
    • 2021-03-30
    • 2015-10-30
    相关资源
    最近更新 更多