Android开发之Animation 4种动画效果

  1. // 演示的代码在activity的onCreate()方法里面,直接加载了ListView的动画效果
  2. AnimationSet set = new AnimationSet(false);  
  3. Animation animation = new AlphaAnimation(0,1);   //AlphaAnimation 控制渐变透明的动画效果   
  4. animation.setDuration(500);     //动画时间毫秒数   
  5. set.addAnimation(animation);    //加入动画集合   
  6.   
  7. animation = new TranslateAnimation(1131050);  //ScaleAnimation 控制尺寸伸缩的动画效果  
  8. animation.setDuration(300);  
  9. set.addAnimation(animation);  
  10.   
  11. animation = new RotateAnimation(30,10);    //TranslateAnimation  控制画面平移的动画效果   
  12. animation.setDuration(300);  
  13. set.addAnimation(animation);  
  14.   
  15. animation = new ScaleAnimation(5,0,2,0);    //RotateAnimation  控制画面角度变化的动画效果   
  16. animation.setDuration(300);  
  17. set.addAnimation(animation);  
  18.   
  19. LayoutAnimationController controller = new LayoutAnimationController(set, 1);  
  20.   
  21.   
  22. GridView gridView = (GridView) this.findViewById(R.id.gridview);  
  23. gridView .setLayoutAnimation(controller);  //GridView 设置动画效果   
  24.   
  25. ListView listview= (ListView)this.findViewById(R.id.listview);  
  26. listview.setLayoutAnimation(controller);   //ListView 设置动画效果  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值