Play GIF image in glide once

你说的曾经没有我的故事 提交于 2020-08-25 07:35:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!