我想在我的android應用程序中以五秒鐘的時間顯示gif圖像(不使用webview)。如果我正在使用ImageView,並向它添加Gif,它不會顯示爲一般Image.Please有關這方面的幫助。如何使gif圖像顯示爲啓動畫面
回答
1.Put compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
。
- 把你的.gif文件的文件夾繪製
調用下面的方法在您的onCreate的SplashActivity
public void startSplash(){
Animation fadeout = new AlphaAnimation(1.f, 1.f);
fadeout.setDuration(2500);
final View viewToAnimate = gifImageView;
fadeout.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
gifImageView.setBackgroundResource(R.drawable.splash_screen);//splash_screen is your .gif file
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
});
gifImageView.startAnimation(fadeout);
}
Put the below code in your SplashActivty.xml
<pl.droidsonroids.gif.GifTextView
android:id="@+id/imageView"
android:layout_width="fill_parent"
android:scaleType="fitXY"
android:layout_height="fill_parent"
/>
轉到您的項目級別的構建.gradle文件並添加下面的代碼,如果它不存在
buildscript {
repositories {
mavenCentral()
}
}
allprojects {
repositories {
mavenCentral()
}
}
或者您也可以嘗試
repositories {
jcenter()
}
感謝您迴應n9153, 得到一個錯誤...未能解決編譯'pl.droidsonroids.gif:android-gif-drawable:1.1。+ – EED
你究竟在哪裏得到這個錯誤?你有沒有添加這個作爲gradle依賴? – Nishith
ya它是我的gradle依賴關係, 依賴項編譯文件樹(dir:'libs',include:['* .jar']) compile'pl.droidsonroids.gif:android-gif-drawable:1.1。+' testCompile'junit:junit:4.12' compile'com.android.support:appcompat-v7:23.3.0' } – EED
嘗試此GIF觀點
使用依賴
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.17'
更換的ImageView這個XML
<pl.droidsonroids.gif.GifImageView android:layout_width="match_parent" android:layout_centerInParent="true" android:layout_height="match_parent" android:src="@drawable/splashbg"/>
將webview設置爲您的閃屏並讓瀏覽器呈現gif。就這樣!對於GIF支持
- 1. 動畫GIF圖像作爲iPhone的啓動畫面
- 2. 啓動畫面中未顯示圖像
- 3. IOS支持顯示GIF動畫圖像?
- 4. jQuery自動完成:如何顯示動畫GIF加載圖像
- 5. 顯示動畫GIF
- 6. 顯示gif動畫
- 7. 如何在Android應用上顯示啓動畫面圖像?
- 8. Qt - 如何在QGraphicsPixmapItem中顯示gif(動畫)圖像
- 9. 從多圖像(動畫)GIF文件顯示單個圖像
- 10. 如何在java中使用動畫gif文件作爲啓動畫面?
- 11. 如何在android中顯示多個圖像作爲啓動畫面?
- 12. 顯示GIF圖像
- 13. 顯示啓動畫面
- 14. 計時動畫gif顯示
- 15. 從桌面圖標啓動時,JNLP不顯示啓動畫面
- 16. 啓動畫面的Android圖像動畫
- 17. 顯示動畫GIF後顯示信息
- 18. python tkinter使用PIL顯示動畫GIF
- 19. 如何在頁面加載時顯示ajax加載gif動畫?
- 20. 如何在android中顯示gif圖像?
- 21. 未能在Android應用程序中顯示動畫GIF圖像
- 22. 在GTK中顯示動畫GIF#圖像構件
- 23. 在android中顯示一個動畫進度條GIF圖像
- 24. GIF圖像沒有在反應本機中顯示動畫
- 25. 啓動畫面中的GIF文件Ionic
- 26. iPhone - 顯示動態啓動畫面
- 27. 在gif上顯示圖像
- 28. 重新啓動GIF動畫
- 29. 顯示動畫圖像
- 30. 如何在新頁面上重新啓動gif動畫?
使用滑翔 – Stallion
感謝您迴應SilentKiller ....到現在我已經嘗試添加gif圖片作爲源的ImageView,但它只是顯示爲JPG格式的圖像 – EED