Xamarin GIF animation

Viewed 6062

I just started developing Xamarin But I encountered a problem I have a login screen and I want to play gif there but unfortunately no images are coming

Works well for png and jpeg files

my code is below;

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
                }
            };
1 Answers

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 of false. This property, of type bool, 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 to true.

Modify code of Image as bellow :

new Image { Source = "a.jpg", IsAnimationPlaying = true}

For example , this is my gif file :

enter image description here

Xaml code :

<Label Text="Welcome to Xamarin.Forms!" HorizontalOptions="Center" VerticalOptions="Start" />
<Image Source="timg.gif" IsAnimationPlaying="True"/>

The effect :

enter image description here

Related