gpt4 book ai didi

c# - 使用 Xamarin.Forms 显示来自 URL 的图像

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:06:21 25 4
gpt4 key购买 nike

我正在使用此代码显示来自 URL 的图像

.xaml

<?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="LandAHand.VolunteerView">
<ContentPage.Content>
<AbsoluteLayout BackgroundColor="Maroon">
<Image x:Name="backgroundImage" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Aspect="AspectFill" />
</AbsoluteLayout>
</ContentPage.Content>
</ContentPage>

.cs

using System;
using System.Collections.Generic;

using Xamarin.Forms;

namespace LandAHand
{
public partial class VolunteerView : ContentPage
{
public VolunteerView()
{
InitializeComponent();
backgroundImage.Source = new UriImageSource
{
Uri = new Uri("https://s9.postimg.org/aq1jt3fu7/handshake_87122244_std.jpg"),
CachingEnabled = true,
CacheValidity = new TimeSpan(5, 0, 0, 0)
};
}
}
}

此代码可成功用于 iOS,但不适用于 Android。

最佳答案

好吧,你可以用你的 Xaml 做这件事更容易,只需像这样制作你的 xaml

<Image x:Name="backgroundImage" Source="https://s9.postimg.org/aq1jt3fu7/handshake_87122244_std.jpg" AbsoluteLayout.LayoutBounds="0,0,1,1"   AbsoluteLayout.LayoutFlags="All" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Aspect="AspectFill"/>

并去掉后面代码中相关的代码。提现默认开启24小时

关于c# - 使用 Xamarin.Forms 显示来自 URL 的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38910715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com