listView添加動畫

//ListView設置動畫

mListView.setLayoutAnimation(InLayoutAnim.getAnimationController(300));


public static LayoutAnimationController getAnimationController(int mDuration) {

int duration = 300;

if(mDuration>300)

duration=mDuration;

AnimationSet set = new AnimationSet(true);

 

Animation animation = new AlphaAnimation(0.0f, 1.0f);

animation.setDuration(duration);

set.addAnimation(animation);

 

animation = new TranslateAnimation(

Animation.RELATIVE_TO_SELF, 1.0f,

Animation.RELATIVE_TO_SELF, 0.0f,

Animation.RELATIVE_TO_SELF, 0.0f,

Animation.RELATIVE_TO_SELF, 0.0f);

animation.setDuration(duration);

set.addAnimation(animation);

 

LayoutAnimationController controller = new LayoutAnimationController(set, 0.25f);

controller.setOrder(LayoutAnimationController.ORDER_NORMAL);

return controller;

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章