我正在尝试在我的项目中模仿Google Plus应用,因为现在它似乎是参考。
当滚动时,列表视图的效果非常好,我想做类似的东西。
我已经开始使用LayoutAnimationController http://android-er.blogspot.be/2009/10/listview-and-listactivity-layout.html
LayoutAnimationController controller
= AnimationUtils.loadLayoutAnimation(
this, R.anim.list_layout_controller);
getListView().setLayoutAnimation(controller);
这似乎不太好,因为并非所有的元素都被动画化了:
因此,最终我使用了适配器的getView方法,并使用了以下代码:
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(800);
set.addAnimation(animation);
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(600);
set.addAnimation(animation);
row.startAnimation(set);
结果非常棒,我真的很满意!
不幸的是,只有当我从列表顶部向底部滚动时才有效!
我想让它在从另一侧滚动时也能正常工作,我需要稍微改变TranslateAnimation。
所以我的问题是,在我的适配器中有没有一种方法可以检测我是向上还是向下滚动?