閱讀323 返回首頁    go 技術社區[雲棲]


Android ListView Animation 4種動畫效果(貼上了GIF圖)

Animation是android的動畫效果的組件,可以實現絢麗的翻頁、ListView和GridView的展示。

 

這blog簡單介紹一下4種動畫效果方式:

1.  AlphaAnimation               控製漸變透明的動畫效果    如圖:

Animation 4種動畫效果(貼上了GIF圖)


2.  ScaleAnimation               控製尺寸伸縮的動畫效果 如圖:

 

Animation 4種動畫效果(貼上了GIF圖)


3.  TranslateAnimation        控製畫麵平移的動畫效果  如圖:

 

Animation 4種動畫效果(貼上了GIF圖)


4.  RotateAnimation             控製畫麵角度變化的動畫效果    如圖:

 

Animation 4種動畫效果(貼上了GIF圖)

 

具體的使用方法,直接上代碼。注:我演示的代碼在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 設置動畫效果



也可以這麼實現:

https://blog.csdn.net/jdsjlzx/article/details/7652452


最後更新:2017-04-02 16:47:36

  上一篇:go android圖片倒影控件ReflectionImage
  下一篇:go Android中使用Animation實現控件的動畫效果以及Interpolator和AnimationListener的使用