一次滑动播放GIF图像 [英] Play GIF image in glide once

查看:70
本文介绍了一次滑动播放GIF图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到如何在图像按钮中设置GIF图像并将其设置为仅播放一次的方法.

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

推荐答案

请尝试添加RequestListener.并在OnResourceReady()中设置循环计数. 例如:

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

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

Please check the following link for more information: https://github.com/bumptech/glide/issues/1706#issuecomment-282827419

这篇关于一次滑动播放GIF图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆