我刚开始开发Xamarin,但我遇到了一个问题,我有一个登录屏幕,我想在那里播放gif,但不幸的是,没有图像来
适用于png和jpeg文件
我代码如下;
Content = new StackLayout
{
Padding = new Thickness(10, 40, 10, 10),
Children = {
new Label { Text = "Versiyon:"+DependencyService.Get<INativeCall>().getApplicationVersion(), FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), TextColor = Color.White, HorizontalTextAlignment=TextAlignment.Center },
new Image { Source = "a.gif" },
username,
password,
btnLogin,
indicator,
infoServer,
infoUpdate
}
};
2条答案
按热度按时间mcdcgff01#
By default, when an animated GIF is loaded it will not be played. This is because the
IsAnimationPlaying
property, that controls whether an animated GIF is playing or stopped, has a default value offalse
. This property, of typebool
, is backed by a BindableProperty object, which means that it can be the target of a data binding, and styled.Therefore, when an animated GIF is loaded it will not be played until the
IsAnimationPlaying
property is set totrue
.Modify code of
Image
as bellow :For example , this is my gif file :
Xaml code :
The effect :
lstz6jyr2#
请使用nuget包-Xamarin.FFImageLoading。它处理GIF文件的速度很快。
例如XAML -
<ffimageloading:SvgCachedImage Grid.Row="3" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Source="celebrate.gif" />