ListView动画效果

默认的listView的加载样式比较生硬,如果想修改其实很简单,例如google+加载样式就比较舒服,其实只需要设置一个参数即可:
mListView.setLayoutAnimation(getListAnimStyle());
其中这个getListAnimStyle()也就是你想要的效果,需要自己实现。

public LayoutAnimationController getListAnimStyle() {
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(300);
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 = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
-1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(500);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(
set, 0.5f);
return controller;
}
其实最主要的就是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);
修改参数即可。

你可能感兴趣的:(ListView加载样式)