首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >交替触觉动画

交替触觉动画
EN

Stack Overflow用户
提问于 2013-09-17 06:36:01
回答 1查看 447关注 0票数 0

对于相同的视图,我有两个转换动画类,我现在想要的是,我需要这个视图来获得隐藏/显示,使用替代的触摸。当组合在一起时,只有一个动画是工作的,我需要两个工作的交替接触。这是我的密码。

代码语言:javascript
复制
ln.setOnTouchListener(new View.OnTouchListener() 
        {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) 
            {
                if(motionEvent.getAction() == MotionEvent.ACTION_DOWN)
                {
                    Animation animation = new TranslateAnimation(0,-200,0, 0);
                    animation.setDuration(2000);
                    animation.setFillAfter(true);
                    lv.startAnimation(animation);
                    lv.setVisibility(0);

                    }
                    else
                    {
                     Animation animation = new TranslateAnimation(-200,0,0, 0);
                        animation.setDuration(3000);
                        animation.setFillAfter(true);
                        lv.startAnimation(animation);
                      lv.setVisibility(0);

                }


                return true;
            }
        });
    }

我提到了this,但我仍然面临着这个问题。有人能告诉我怎么解决这个问题吗。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-23 05:10:05

最后,我找到了解决问题的办法。这是密码。

代码语言:javascript
复制
layout.setOnTouchListener(new View.OnTouchListener() 
 {
     @Override
     public boolean onTouch(View view, MotionEvent motionEvent) 
     {
         if(motionEvent.getAction() == MotionEvent.ACTION_DOWN)
         {
            if(gone)
            {
                 Animation animation = new TranslateAnimation(-300,0,0, 0);
                 animation.setFillAfter(true);
                 animation.setDuration(500);
                 lv.setAnimation(animation);

                 gone = false;

            }
            else
            {
                 Animation animation = new TranslateAnimation(0,-300,0, 0);
              animation.setFillAfter(true);
              animation.setDuration(500);
                 lv.setAnimation(animation);
                 gone = true;
            }
         }
        return true;
     }
 });

布尔值gone = false;在顶部。希望这会对一些人有所帮助:

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18842813

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档