Reputation: 25
I know that xamarin forms currently support playing gif. I've already tried the link https://github.com/jfversluis/AnimatedGifForms/ But It seems to work only for the gifs with the type in the example, I've tried another gif and it can not load on android. It works perfectly on the IOS. There are any config that I can do for playing gif in xamarin forms I'm using Xamarin.form 4.6, and the latest Xamarin.Essential 1.5.3
Upvotes: 1
Views: 917
Reputation: 15816
You can use Image control to load gif in Xamarin.forms.
<StackLayout>
<!-- Place new controls here -->
<Image Source="sample.gif" IsAnimationPlaying="True"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
Starting and stopping is controlled through IsAnimationPlaying. Originally we were going to use Start and Stop methods but all these did was set IsAnimationPlaying to true or false respectively. This way it can also be started and stopped via Binding!!
I uploaded a sample project here and you can check.
Refer: Gif Animation Support
Update:
Use Xamarin.FFImageLoading.Svg.Forms to load:
xmlns:ffimageloading="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
<StackLayout>
<ffimageloading:SvgCachedImage HorizontalOptions="Center" VerticalOptions="CenterAndExpand" Source="blue.gif" />
</StackLayout>
Don't forget to CachedImageRenderer.Init(true);
in MainActivity
:
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
//Forms.SetFlags("UseLegacyRenderers");
CachedImageRenderer.Init(true);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
Upvotes: 2