android - 在 android 布局中添加 GIF

标签 android xml animated-gif

我正在尝试在 XML 布局中添加 GIF

一开始它工作正常,但是当我关闭 android studio 并再次打开它时 它给我错误!

另外,我尝试降低 GIF 的质量和空间,一开始效果很好,但重启后出错!

这是我的 XML 代码:

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#fff"
    android:orientation="vertical">

    <pl.droidsonroids.gif.GifImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/myimg"/>
</LinearLayout>

错误

enter image description here

最佳答案

您可以将 Glide 用于常规 ImageView

Glide.with(this).load(R.drawable.myimg).into(imageView)

在build.gradle(module:app)中添加如下依赖

implementation 'com.github.bumptech.glide:glide:4.9.0'

导入:

import com.bumptech.glide.Glide

引用:https://www.tutorialspoint.com/how-to-display-animated-gif-images-in-android-using-kotlin

关于android - 在 android 布局中添加 GIF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42898968/

相关文章:

java - PHP API 中的语法错误

android - Osmdroid:渲染具有透明度的图 block

php - 使用 PHP simpleXML 查找我知道名称但不知道其所在位置的节点

ios - UIImageView 中的动画 gif

javascript - 我怎样才能在 JavaScript 处理期间(因为它卡住)继续播放我的 GIF?

android - AppFlow 电容器构建错误 : PermissionDenied gradlew

安卓:支持多屏

javascript - XMLHttpRequest 之后的innerHTML 在 IE9 上不起作用

java - 合并 list 失败

animated-gif - 如何让favicon动画连续循环?