我试图找到如何在图像按钮中设置GIF图像并将其设置为仅播放一次。
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);
请尝试添加RequestListener
。并在OnResourceReady()
中设置循环计数。例如:
Glide.With(this).AsGif().Load(Resource.Mipmap.giphy).Listener(new MyRequestListener()).Into(ib_main_home);
和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;
}
}
请查看以下链接以获取更多信息:https://github.com/bumptech/glide/issues/1706#issuecomment-282827419