我是android初學者。我需要在應用程序中實現逐幀動畫,但是它已經完成了我不知道請給我一個完整的框架框架動畫的例子。這是我能想到的,現在ANDROID - Frame By Frame動畫
1
A
回答
2
嗨,你可以通過這一步做到這一點。
第1步:將圖像插入需要構圖的可繪製文件夾中。
步驟2:爲FrameByFrame動畫的配置創建一個xml,並將其放置到res/drawable文件夾中。 這裏有兩個圖像用於動畫是f1和f2。 android:持續時間定義更改幀的時間(以毫秒爲單位)。
<?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/f1"
android:duration="50"/>
<item
android:drawable="@drawable/f2"
android:duration="50"/>
</animation-list>
3步:創建main.xml中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
第4步:在MainActivity.java
最後執行
public class MainActivity extends Activity {
ImageView iv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Imageview in which images load one by one like Frame By Frame
iv = (ImageView) findViewById(R.id.imageView1);
//Bind xml which is configure animation.
AnimationDrawable ad = (AnimationDrawable) getResources().getDrawable(
R.drawable.sam);
iv.setBackgroundDrawable(ad);
//Start animation
ad.start();
//For stop animation you can use ad.stop();
}
}
0
2種方式是:
- 嘗試創建可繪製的動畫列表,並使用它們
- 試着畫使用畫布框在Android
相關問題
- 1. android frame by frame動畫問題
- 2. android frame-by-frame動畫和翻譯
- 3. Large Frame By Frame Animation Android
- 4. android frame by frame動畫 - 與這兩個代碼的區別
- 5. Android Frame by Frame CursorAdapter中的元素動畫問題
- 6. Android Frame by Frame動畫問題內存不足或緩慢動畫
- 7. A-Frame 0.6.1 - 相機旋轉動畫
- 8. Java Game Dev:Sprite sheet frame by row and column?
- 9. WPF:InkCanvas + Frame
- 10. Frame ViewModel
- 11. i-frame滾動的對象
- 12. java show hide frame
- 13. info frame vs Tcl_Eval
- 14. Ireport Frame Issue
- 15. Swing Popup Frame
- 16. Frame ContentLoaded event
- 17. UISearchDisplayController Frame問題
- 18. ifign/frame in codeigniter
- 19. frame not recognized
- 20. Scrape inner frame HTML
- 21. android capture video frame
- 22. python selenium hidden frame
- 23. Data Frame into bin
- 24. X-Frame ORIGINS IFRAME
- 25. Android Frame Animation
- 26. LibGDX gwt frame drop
- 27. A-frame fadeOut primitives
- 28. Shift A-Frame Origin
- 29. Chrome-frame 25.0.1364.97 rendering
- 30. Swift:Size vs bounds vs frame
您可以檢查http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html和https://www.bignerdranch.com/blog/frame-animations-in-android/ – Aayushi