问题
I'm trying to find how can I set a GIF image in image button and set it to play only once.
SetContentView(Resource.Layout.activity_main);
var ib_main_home = FindViewById<ImageButton>(Resource.Id.ds);
Glide.With(this).AsGif()
.Load(Resource.Mipmap.giphy)
.Into(ib_main_home);
回答1:
Please try to add a RequestListener
. And set the loop count in OnResourceReady()
.
For example:
Glide.With(this).AsGif().Load(Resource.Mipmap.giphy).Listener(new MyRequestListener()).Into(ib_main_home);
And the RequestListener
:
public class MyRequestListener :Java.Lang.Object, IRequestListener
{
public bool OnLoadFailed(GlideException p0, Java.Lang.Object p1, ITarget p2, bool p3)
{
return true;
}
public bool OnResourceReady(Java.Lang.Object p0, Java.Lang.Object p1, ITarget p2, DataSource p3, bool p4)
{
if (p0 is GifDrawable)
{
((GifDrawable)p0).SetLoopCount(1);
}
return false;
}
}
Please check the following link for more information: https://github.com/bumptech/glide/issues/1706#issuecomment-282827419
来源:https://stackoverflow.com/questions/52854364/play-gif-image-in-glide-once