[英]Having troubles loading a GIF image in my application
所以我試圖使用鏈接將 GIF 圖像加載到我的應用程序中,但我找不到方法。
我嘗試使用 Glide 和 Picasso 但我仍然無法解決我的問題,起初我以為我的應用程序中可能有一些東西阻止了 GIF 加載所以我嘗試創建一個新應用程序只是為了測試在應用程序中加載 GIF 和仍然無法加載單個 GIF。
我環顧四周尋找像我這樣的問題並測試了一些給出的答案,但沒有一個有效!
因此,如果有人能告訴我一種在應用程序中加載 GIF 的方法,我將非常感激,我可以分享我的應用程序的代碼,但正如我之前所說,我正在嘗試一個新的空應用程序並且其中沒有實際代碼。
信息太少,無法知道發生了什么。 最好顯示有關您嘗試的代碼和結果的更多詳細信息。
然而,這是一個簡單的例子
AndroidManifest.xml :
添加互聯網權限
<uses-permission android:name="android.permission.INTERNET" />
build.gradle(:app) :
添加滑翔庫。
implementation 'com.github.bumptech.glide:glide:4.12.0'
activity_main.xml :
添加一個 ImageView
<ImageView
android:id="@+id/imageView"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
MainActivity.kt:
將 GIF 加載到 imageView
val url = "https://media.giphy.com/media/3o7527pa7qs9kCG78A/giphy.gif"
Glide.with(this)
.load(url)
.into(imageView)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.