【问题标题】:How to retrieve gif asset from firebase storage ? Kotlin Android Studio如何从 Firebase 存储中检索 gif 资产? Kotlin 安卓工作室
【发布时间】:2021-08-18 00:48:36
【问题描述】:

我尝试从 firebase 存储中检索 gif 资源,但我遇到了一个问题,即 gif 变成了图像

这里是我的 onCreate 函数:

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_practice)

    val storageRef = FirebaseStorage.getInstance().reference.child("gif/step1.gif")
    val localFile = File.createTempFile("tempGif", "gif")
    storageRef.getFile(localFile).addOnSuccessListener {

        val bitmap = BitmapFactory.decodeFile(localFile.absolutePath)
        img.setImageBitmap(bitmap)
    }.addOnFailureListener {
        Toast.makeText(this, "Failed to retrieve the image", Toast.LENGTH_SHORT).show()
    }

    init()
    dataSet()
    interaction()
}

我正在使用 GifImageView 库,下面是我的布局 XML 的屏幕截图:

我在这里分享应用输出截图:

任何帮助和解决方案,我都非常感谢... 谢谢!

【问题讨论】:

    标签: android firebase kotlin firebase-storage


    【解决方案1】:

    我查看了你的用法,把东西放在一起很简单

    val gifFromPath =  GifDrawable( localFile.absolutePath )
    img.setImageDrawable(gifFromPath)
    

    https://github.com/koral--/android-gif-drawable

    【讨论】:

      猜你喜欢
      • 2017-02-25
      • 2015-05-25
      • 2018-11-06
      • 2022-01-01
      • 2017-02-09
      • 2019-05-13
      • 2018-03-05
      • 1970-01-01
      • 2023-03-21
      相关资源
      最近更新 更多