末我有看法是这样的:动画/隐藏按钮时接近的ListView
ListView的是整个屏幕上的按钮始终可见(上的FrameLayout)。当用户滚动列表并且他到达结尾时(动画必须在他到达结尾之前开始,以便它可以很好地移出屏幕),我想用动画在屏幕之外(下面)隐藏按钮。如何实现这一目标?
编辑
由于PPartisan我创建简单的方法onScroll这是工作得非常好:
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
final int lastItem = firstVisibleItem + visibleItemCount;
if(lastItem == totalItemCount & button.getVisibility() == View.VISIBLE & hideAnimStarted == false) {
hideAnimStarted = true;
ObjectAnimator animator = ObjectAnimator.ofFloat(button, View.TRANSLATION_Y, 100);
animator.setDuration(300);
animator.start();
animator.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) { }
@Override
public void onAnimationRepeat(Animator animation) { }
@Override
public void onAnimationEnd(Animator animation) {
button.setVisibility(View.GONE);
}
@Override
public void onAnimationCancel(Animator animation) {}
});
}
else if(lastItem < totalItemCount & button.getVisibility() == View.GONE){
button.setVisibility(View.VISIBLE);
hideAnimStarted = false;
ObjectAnimator animator = ObjectAnimator.ofFloat(button, View.TRANSLATION_Y, 0);
animator.setDuration(300);
animator.start();
}
}
谢谢,但我想按钮只隐藏在列表的末尾没有任何其他地方,所以如何检测使用onInterceptTouchEvent达到列表的结束? – user3626048 2015-04-04 22:01:22
在这种情况下,我会反过来聆听ListView中的项目位置。看看我更新的答案和我提供的链接 - 这是未经测试的,但我将如何处理它。 – PPartisan 2015-04-04 22:22:46