首页 > 解决方案 > XAML 图像源在跨平台(Android 模拟器)中不起作用

问题描述

我正在尝试设计一个类似于 Instagram 的 UI(这是一个练习),并且无法从 URL 显示图像。似乎代码是正确的,但它不起作用。

    <StackLayout>
        <Label TextColor="Black" Text="nyc_photographer"/>
    </StackLayout>

    <!--Image not showing-->
    <Image Source="http://lorempixel.com/1920/1080/nature/3/"/>

    <StackLayout Orientation="Horizontal" Spacing="20">
        <Button TextColor="Blue" Text="Like" BackgroundColor="Transparent" />
        <Button TextColor="Blue" Text="Comment" BackgroundColor="Transparent"/>
        <Button TextColor="Blue" Text="Share" BackgroundColor="Transparent"/>
     </StackLayout>

    <StackLayout>        
        <BoxView Color="#f0f0f0" HeightRequest="1" />
        <Label Text="700 likes" FontAttributes="Bold" TextColor="Black"/>
        <Label TextColor="#444" Text="This is a shot yesterday in Skanor, Sweden, when driving home, from a couple of days of work in Denmark." />
    </StackLayout>

</StackLayout>

在昵称 nyc_photographer 和 Like 按钮后应该出现图像。我展示了预期结果应该如何的图像。

我展示了预期结果应该如何的图像。

标签: androidxamlxamarin

解决方案


实际上,这似乎是问题所在......我的 AVD 没有互联网连接,但笔记本电脑确实有

我用cmd命令解决了启动emu的问题。%AppData%\Local\Android\Sdk\emulator> emulator.exe -avd avdname -dns-server 8.8.8.8

在此处输入图像描述


推荐阅读