android中3种实现动画效果的方法

时间:2023-03-09 22:34:19
android中3种实现动画效果的方法

3中实现动画的方法:
ImageView imgView = (ImageView)findViewById(R.id.imageView_logo);

//第一种动画方法,使用AlphaAnimation实现动画(图片由暗变亮的过程)
//animation = new AlphaAnimation(0.0f, 1.0f);
//第二种动画方法,使用ScaleAnimation实现,动画由小变大
animation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
//下面是第三种方法,但是后面的两个参数不理解(随便赋值的),不过也能够实现
//animation = new RotateAnimation(TRIM_MEMORY_COMPLETE, BIND_ABOVE_CLIENT);

animation.setDuration(1000); //动画开始到结束过程的持续时间
animation.setAnimationListener(animationListener);//设置动画的监听
imgView.startAnimation(animation);