[英]how to achieve car moving animation in MapMyIndia android SDK
[英]How to achieve this type of animation in the Android SDK?
看看我為要在Android上開發的游戲界面所做的設計: http : //www.moboing.com/smallshow.jpg
當用戶觸摸氣球時,我希望該星星/眩光動畫在星星掉落的情況下播放。 我唯一想知道的是在eclipse / java中開發應用程序時使該動畫成為可能的最佳通用方向/方法。
我當時在考慮將星星的一些變體作為透明的PNG,並使它們在觸摸時具有動畫效果,但是我是新手,因此我不確定。
您可以像創建圖像序列一樣創建動畫,然后使用AnimationDrawable類使其動畫化。 讓我給你看一個例子:
ImageView my_image = (ImageView) findViewById(R.id.my_animation);
AnimationDrawable animation = new AnimationDrawable();
// We need to add each image to our final animation setting time interval between them
animation.addFrame(getResources().getDrawable(R.drawable.img_1), 200);
animation.addFrame(getResources().getDrawable(R.drawable.img_2), 200);
animation.addFrame(getResources().getDrawable(R.drawable.img_3), 200);
animation.setOneShot(false);
my_image.setBackgroundDrawable(animation); // Set as background to see it
animation.start(); // Start playing the animation
哪里:
my_animation
:將您的ImageView轉換成您想要的布局。 img_1
, img_2
, img_3
:合成動畫的圖像(您應該創建並將其保存到res/drawable
文件夾中)。 希望它能對您有所幫助,並為您自己做一個辦法:)
PS:這應該在所需活動的方法中(例如,在onCreate
中在用戶啟動時顯示它)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.