我正在使用正常圖像視圖來顯示來自我的服務器的圖像,現在我想要顯示gif動畫,但不知道如何去做,請問您能幫我嗎?在android中顯示gifs
1
A
回答
1
您可以使用一個名爲滑翔庫,檢查此鏈接 https://github.com/bumptech/glide
的依賴添加到您的build.gradle
dependencies {
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:19.1.0'
}
要顯示您的GIF的ImageView使用此示例:
ImageView imageView = (ImageView) findViewById(R.id.imageView);
Glide.with(context)
.load(imageUrl)
.asGif()
.crossFade()
.into(imageView);
+0
是的,但我不善於使用庫 – user3693698
2
我在我的項目中使用這個庫https://github.com/koral--/android-gif-drawable
它在RecyclerView中完美工作。
使用庫是非常簡單,只需添加
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.16'
您的build.gradle文件 ,並用它在你的佈局像這樣
<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/src_anim"
android:background="@drawable/bg_anim"
/>
或者你也可以從使用這樣的代碼:
GifDrawable gifFromPath = new GifDrawable("/path/anim.gif");
相關問題
- 1. 在collectionview中顯示很多gifs
- 2. 減慢foreach,所以我可以顯示所有GIFS
- 3. 顯示在Android
- 4. 在Android中顯示圖片
- 5. Android:在OnSeekBarChangeListener中顯示Toast?
- 6. 在android中顯示Feed
- 7. 在ImageView中顯示Uri Android
- 8. android在TextView中不顯示「」?
- 9. 在android中顯示路線
- 10. Exoplayer在android中顯示Runtimeexception
- 11. 在android中顯示數據
- 12. Android:在ListView中顯示XML
- 13. 在android中沒有顯示
- 14. 更新顯示在Android中
- 15. 黑屏在Android中顯示
- 16. 在android中顯示通知
- 17. Android在ListView中顯示HTML
- 18. Android在OnResume中顯示ProgressDialog()
- 19. 顯示在Android的
- 20. 與Kusaba上傳大型GIFS
- 21. Gifs,Javascript和多個實例
- 22. C# - picturebox中的多個動畫gifs
- 23. Android版本2.2中顯示的Google地圖,未在Android版本2.1中顯示
- 24. Android:在顯示網格中顯示文本的簡單GridView
- 25. Android:圖片不顯示在照片顯示中活動
- 26. 通知沒有顯示Android 7.0,但顯示在Android 6.0
- 27. 如何在android中顯示文本?
- 28. 在Android中搜索時顯示ProgressDialog
- 29. 在ViewPager中顯示兩個項目android
- 30. 在Android中顯示錶格數據
參考這個鏈接http://stackoverflow.com/questions/3660209/display-animated-gif –