Enes Deniz
Enes Deniz

Reputation: 41

Xamarin GIF animation

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

Upvotes: 2

Views: 9877

Answers (2)

Joginder Tanikella
Joginder Tanikella

Reputation: 136

Please use the nuget package - Xamarin.FFImageLoading.It processes GIFs quickly.

eg XAML -
<ffimageloading:SvgCachedImage Grid.Row="3" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Source="celebrate.gif" />

Upvotes: 0

Junior Jiang
Junior Jiang

Reputation: 12723

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

Upvotes: 8

Related Questions