`
mermaid
  • 浏览: 40427 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

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);
修改参数即可。
0
2
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics