- // 演示的代码在activity的onCreate()方法里面,直接加载了ListView的动画效果
- AnimationSet set = new AnimationSet(false);
- Animation animation = new AlphaAnimation(0,1); //AlphaAnimation 控制渐变透明的动画效果
- animation.setDuration(500); //动画时间毫秒数
- set.addAnimation(animation); //加入动画集合
- animation = new TranslateAnimation(1, 13, 10, 50); //ScaleAnimation 控制尺寸伸缩的动画效果
- animation.setDuration(300);
- set.addAnimation(animation);
- animation = new RotateAnimation(30,10); //TranslateAnimation 控制画面平移的动画效果
- animation.setDuration(300);
- set.addAnimation(animation);
- animation = new ScaleAnimation(5,0,2,0); //RotateAnimation 控制画面角度变化的动画效果
- animation.setDuration(300);
- set.addAnimation(animation);
- LayoutAnimationController controller = new LayoutAnimationController(set, 1);
- GridView gridView = (GridView) this.findViewById(R.id.gridview);
- gridView .setLayoutAnimation(controller); //GridView 设置动画效果
- ListView listview= (ListView)this.findViewById(R.id.listview);
- listview.setLayoutAnimation(controller); //ListView 设置动画效果
Android开发之Animation 4种动画效果
最新推荐文章于 2022-11-27 12:46:00 发布