ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Frame Animation 공부
    과거...../개발일지 2010. 3. 8. 21:06

     

    --MainActivity source--

     package com.ex;

    import android.app.Activity;
    import android.graphics.drawable.AnimationDrawable;
    import android.os.Bundle;
    import android.view.MotionEvent;
    import android.widget.ImageView;

    public class MainActivity extends Activity {
       
     AnimationDrawable rocketAnimation;
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
           
            ImageView rocketImage = (ImageView) findViewById(R.id.ImageView01);
            rocketImage.setBackgroundResource(R.anim.rocket_thrust);
            rocketAnimation = (AnimationDrawable)rocketImage.getBackground();      
        }
       
        public boolean onTouchEvent(MotionEvent event){
         if(event.getAction() == MotionEvent.ACTION_DOWN){
          rocketAnimation.start();
          return true;
         }
         return super.onTouchEvent(event);
         
        }
    }



    -- rocket_thrust.xml--
     <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
     <item android:drawable="@drawable/icon" android:duration="800"></item>
     <item android:drawable="@drawable/app" android:duration="800"></item>
     <item android:drawable="@drawable/icon" android:duration="800"></item>
    </animation-list>


    자세한 설명 바로가기 : http://developer.android.com/guide/topics/graphics/2d-graphics.html#frame-animation

Designed by Tistory.