使用动画刷一下意见 [英] Using Animation to swipe views

查看:66
本文介绍了使用动画刷一下意见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的FrameLayout承认滑动手势(上下)。

I have a FrameLayout that recognize swipe gestures (up and down).

例如:如果一个向上轻扫执行,我应该动画当前视图(即MATCH_PARENT x MATCH_PARENT)以上升的同时一个新的观点来自底部

For example: if a swipe up are performed, I should animate the current view (that is MATCH_PARENT x MATCH_PARENT) to goes up at the same time a new view come from bottom.

我可以用动画实现这一目标?

I can achieve this with animations?

推荐答案

我解决了这种方式:

private void swipeUp() {
    current.currentPage++;

    final View hidingView = currentView;
    TranslateAnimation hide = new TranslateAnimation(0, 0, 0, -getHeight());
    hide.setAnimationListener(new AnimationListenerAdapter() {
        @Override
        public void onAnimationEnd(Animation animation) {
            hidingView.setVisibility(View.GONE);
        }
    });
    hide.setDuration(1000);
    hidingView.startAnimation(hide);

    TranslateAnimation show = new TranslateAnimation(0, 0, getHeight(), 0);
    show.setFillAfter(true);
    show.setDuration(1000);

    View nextView = getView();
    addView(nextView, createLP());

    nextView.startAnimation(show);
    currentView = nextView;
}

这篇关于使用动画刷一下意见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆