我是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 CursorAdapter中的元素動畫問題
- 3. Android Frame by Frame動畫問題內存不足或緩慢動畫
- 4. A-Frame 0.6.1 - 相機旋轉動畫
- 5. Java Game Dev:Sprite sheet frame by row and column?
- 6. WPF:InkCanvas + Frame
- 7. android capture video frame
- 8. LibGDX gwt frame drop
- 9. python selenium hidden frame
- 10. ifign/frame in codeigniter
- 11. info frame vs Tcl_Eval
- 12. Frame ContentLoaded event
- 13. A-frame fadeOut primitives
- 14. Chrome-frame 25.0.1364.97 rendering
- 15. Shift A-Frame Origin
- 16. X-Frame ORIGINS IFRAME
- 17. Data Frame into bin
- 18. cell.imageView!.frame size change。 Swift
- 19. X-Frame-Option問題
- 20. A-frame not loading materials
- 21. jQuery Scrollable Center Active Frame
- 22. 如何更改動畫A-Frame對象的旋轉軸?
- 23. 使用A-Frame播放帶動畫的聲音組件
- 24. 新的Sprite Frame保持與之前的Sprite Frame相同
- 25. a-frame導航欄,只移動horizonal
- 26. Luminus和Re-Frame Uberjar錯誤
- 27. fengyuanchen cropper frame on button點擊
- 28. 使用bootstrap with phoenix:live_reload/frame
- 29. iOS Share Camera Frame as Image
- 30. jQuery Fancybox&Image Frame Size Control
您可以檢查http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html和https://www.bignerdranch.com/blog/frame-animations-in-android/ – Aayushi