Android中的动画处理可以用SurfaceView来处理,研究深的同学们可以做一些游戏什么的好玩的东西,对于浅浅的我们也只是平面的样子了下面直接说一下简单的动画的四种变换方式:

旋转、移动、缩放、淡入淡出,示例如下

public class MainActivity extends Activity {
    private ImageView iv;
                 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        iv = (ImageView) findViewById(R.id.p_w_picpathView1);
        iv.setOnClickListener(new OnClickListener() {
                         
            @Override
            public void onClick(View v) {
                AnimationSet animationSet = new AnimationSet(true);
                AlphaAnimation alpha = new AlphaAnimation(1, 0);
                alpha.setDuration(4000);
                animationSet.addAnimation(alpha);
                iv.setBackgroundResource(R.drawable.i7);
                iv.startAnimation(animationSet);
            }
        });
    }
                 
}
public class MainActivity extends Activity {
    private ImageView iv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        iv = (ImageView) findViewById(R.id.p_w_picpathView1);
        iv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                AnimationSet animationSet = new AnimationSet(false);
                RotateAnimation rotate = new RotateAnimation(0, 360,
                        Animation.RELATIVE_TO_SELF, 0.5f,
                        Animation.RELATIVE_TO_SELF, 0.5f);
                rotate.setDuration(2000);
                animationSet.addAnimation(rotate);
                iv.startAnimation(animationSet);
            }
        });
    }
}
public class MainActivity extends Activity {
    private ImageView iv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        iv = (ImageView) findViewById(R.id.p_w_picpathView1);
        iv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                AnimationSet animationSet = new AnimationSet(true);
                ScaleAnimation scale = new ScaleAnimation(1, 0.25f, 1, 0.25f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
                scale.setDuration(3000);
                animationSet.addAnimation(scale);
//              iv.setBackgroundColor(color.black);
                iv.startAnimation(scale);
            }
        });
    }
}
public class MainActivity extends Activity {
                 
    private ImageView iv;
                 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        iv = (ImageView) findViewById(R.id.p_w_picpathView1);
        iv.setOnClickListener(new OnClickListener() {
                         
            @Override
            public void onClick(View v) {
                AnimationSet animationSet = new AnimationSet(false);
                TranslateAnimation translate  = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1);
                translate.setDuration(4000);
                animationSet.addAnimation(translate);
                iv.startAnimation(animationSet);
            }
        });
    }
}
public class MainActivity extends Activity {
    private ImageView iv;
    //淡入淡出
//  private AlphaAnimation a1 = new AlphaAnimation(1, 0);
//  private AlphaAnimation a2 = new AlphaAnimation(0, 1);
    //缩放
//  private ScaleAnimation a1 = new ScaleAnimation(1, 0.25f, 1, 0.25f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
//  private ScaleAnimation a2 = new ScaleAnimation(0.25f,1,0.25f,1,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
    //移动
//  private TranslateAnimation a1 = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1);
//  private TranslateAnimation a2 = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);
    //旋转
    private RotateAnimation a1 = new RotateAnimation(0,180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    private RotateAnimation a2 = new RotateAnimation(180,0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        iv = (ImageView) findViewById(R.id.p_w_picpathView1);
        iv.setBackgroundResource(R.drawable.i4);
        a1.setDuration(2000);
        a2.setDuration(2000);
        iv.setOnClickListener(new OnClickListener() {
                         
            @Override
            public void onClick(View v) {
                iv.startAnimation(a1);
                             
            }
        });
        a1.setAnimationListener(new AnimationListener() {
                         
            @Override
            public void onAnimationStart(Animation animation) {
            }
                         
            @Override
            public void onAnimationRepeat(Animation animation) {
                // TODO Auto-generated method stub
                             
            }
                         
            @Override
            public void onAnimationEnd(Animation animation) {
                iv.startAnimation(a2);
                             
            }
        });
    }
                 
}

效果请在模拟器中观察哈~