當您需要更改ProgressBar的背景圖像時,需要採取的適當措施是什麼?我的意思是應該使用一個.gif圖像,如:http://2.bp.blogspot.com/-O7nsXfmgwSc/T6PQ0PVr6-I/AAAAAAAAAQI/-eXkEXj24-s/s1600/02.gif,如果是這樣,條的前景色會在進程中填充圖像文件?有沒有爲酒吧的背景創建動畫的方法?我的目標是顯示動畫,只要這個過程不包含完整的欄。Android上的ProgressBar上的背景動畫圖像?
8
A
回答
14
您需要將所有此gif幀圖像作爲單獨的,然後設置到xml文件中的動畫列表中。
這是您的anim_progress.xml文件代碼
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/i1" android:duration="500" />
<item android:drawable="@drawable/i2" android:duration="500" />
<item android:drawable="@drawable/i3" android:duration="500" />
<item android:drawable="@drawable/i4" android:duration="500" />
<item android:drawable="@drawable/i5" android:duration="500" />
<item android:drawable="@drawable/i6" android:duration="500" />
<item android:drawable="@drawable/i7" android:duration="500" />
<item android:drawable="@drawable/i8" android:duration="500" />
</animation-list>
設置變化平滑效果的持續時間給了動畫形象如GIF
下面是使用此文件
ImageView iv = new ImageView(this);
iv.setBackgroundResource(R.drawable.anim_progress);
final AnimationDrawable mailAnimation = (AnimationDrawable) iv.getBackground();
iv.post(new Runnable() {
public void run() {
if (mailAnimation != null) mailAnimation.start();
}
});
代碼
setContentView(iv);
你可以從這個網站的gif文件獲取所有幀。
例如
http://2.bp.blogspot.com/-O7nsXfmgwSc/T6PQ0PVr6-I/AAAAAAAAAQI/-eXkEXj24-s/s1600/02.gif
此鏈接只是通過它,你會得到所有的幀圖像
相關問題
- 1. 在背景圖像上動畫UIImageView
- 2. 白色背景上的ProgressBar
- 3. 背景圖片上的背景圖像
- 4. 背景圖片上的動畫效果
- 5. Android:如何在背景圖像上創建動畫
- 6. 從Android上的圖像設置背景
- 7. ScrollingActivity頭上的背景圖像Android
- 8. 背景上的Android PNG透明圖像
- 9. 背景動畫圖像
- 10. 動畫UIButton背景圖像
- 11. 背景圖像動畫
- 12. jQuery背景圖像動畫
- 13. CSS背景圖像動畫
- 14. 在畫布上繪製背景圖像
- 15. 上傳圖像作爲背景畫布
- 16. 像啓動畫面的背景圖像
- 17. Android動畫背景圖片
- 18. BlackBerry上的背景圖像
- 19. 背景圖像上的iOS
- 20. JFrame上的背景圖像
- 21. Windows 8上的背景圖像應用程序啓動畫面
- 22. 圖像上的背景位置是否停止動畫?
- 23. 在列表視圖上動畫背景
- 24. 背景圖像上的圖像
- 25. Android中的AsyncTask:如何設置背景圖像的ProgressBar?
- 26. 動畫虛線SVG的背景圖像
- 27. WP8中的動畫背景圖像
- 28. 大圖像背景的Ch啪動畫
- 29. JS動畫的背景圖像縮放
- 30. 按鈕的動畫背景圖像
非常感謝,我想這一點,並讓你知道! – JimBoyHac
像冠軍一樣工作! – JimBoyHac
關於如何將ImageView設置爲進度條背景的任何想法? – JimBoyHac