首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

ListView卡通片效果

2013-07-16 
ListView动画效果默认的listView的加载样式比较生硬,如果想修改其实很简单,例如google+加载样式就比较舒服

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);
修改参数即可。

热点排行