相关疑难解决方法(0)

在Android中的ImageView中添加gif图像

我在imageView中添加了一个动画gif图像.我无法将其视为gif图像.没有动画.它看起来像一个静止图像.我想知道如何将其显示为gif图像.

android gif imageview

117
推荐指数
10
解决办法
27万
查看次数

可以在Android中将动画gif文件设置为动态壁纸吗?

我是Android平台的新手.我想开发一个动态壁纸应用程序.当我在搜索引擎中对此进行搜索时,他们中的许多人创建了一个动态壁纸作为他们的代码(使用SurfaceViewCanvas),我对此并不十分了解.我怀疑的是,任何可能将.gif图像设置为动态壁纸.

android

24
推荐指数
1
解决办法
3万
查看次数

使用Glide,我如何作为Bitmap遍历GifDrawable的每一帧?

背景

在动态壁纸中,我有一个Canvas实例,我希望将GIF/WEBP内容绘制成,通过Glide加载.

我想与滑翔做到这一点,原因是它在我过去找到了同样的事情(的解决方案提供了一些优势在这里,仓库在这里):

  1. 电影的使用限制我只使用GIF.有了Glide,我也可以支持WEBP动画
  2. 电影的使用似乎效率低,因为它没有告诉我在帧之间等待的时间,所以我必须选择我想尝试使用的FPS.它在Android P上也被弃用了.
  3. Glide可能能够轻松处理各种缩放.
  4. Glide可能不会像原始代码一样崩溃,并可能提供更好的机制控制.

问题

Glide似乎已经过优化,只能用于普通的UI(视图).它有一些基本的功能,但对我正在尝试做的最重要的功能似乎是私密的.

我发现了什么

我使用官方Glide库(v 3.8.0)进行GIF加载,使用GlideWebpDecoder进行WEBP加载(使用相同版本).

加载其中每个的基本调用是这样的:

GIF:

    GlideApp.with(this).asGif()
            .load("https://res.cloudinary.com/demo/image/upload/bored_animation.gif")
            .into(object : SimpleTarget<GifDrawable>() {
                override fun onResourceReady(resource: GifDrawable, transition: Transition<in GifDrawable>?) {
                    //example of usage:
                    imageView.setImageDrawable(resource)
                    resource.start()
                }
            })
Run Code Online (Sandbox Code Playgroud)

WEBP:

        GlideApp.with(this).asDrawable()
                .load("https://res.cloudinary.com/demo/image/upload/fl_awebp/bored_animation.webp")
//                .optionalTransform(WebpDrawable::class.java, WebpDrawableTransformation(CircleCrop()))
                .into(object : SimpleTarget<Drawable>() {
                    override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
                        //example of usage:
                        imageView.setImageDrawable(resource)
                        if (resource is Animatable) {
                            (resource as Animatable).start()
                        }
                    }
                })
Run Code Online (Sandbox Code Playgroud)

现在,请记住我并没有真正的ImageView,而是我只有一个Canvas,我可以通过surfaceHolder.lockCanvas()调用获得. …

android animated-gif android-glide animated-webp

9
推荐指数
2
解决办法
1473
查看次数