如何编写动画后视图的onclick监听器? [英] How to write the onclick listener for a view after animation?

查看:98
本文介绍了如何编写动画后视图的onclick监听器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从动画一个地方到另一个视图,后做动画我已经写了code这样的,

I have animating the view from one place to another, after animation done I have written the code like this,

    public void onAnimationEnd(Animation animation) {
            imageView.setOnClickListener(this); 
        }

但我不能可以点击这一观点。从这一观点没有响应。

But I cant able to click that view. No response from that view.

推荐答案

您应该动画到新的位置后,移动视图。您可以使用的LayoutParams。使用code这样的..

You should move the view after the animation to the new position. You can use LayoutParams. use the code like this..

      transAnimation= new TranslateAnimation(0, 
 sourceX-destinationX,0,sourceY-destinationY); // right to left

             transAnimation.setDuration(1000);
             //transAnimation.setFillEnabled(true);
             transAnimation.setFillAfter(false);
             view.startAnimation(transAnimation);

transAnimation.setAnimationListener(new AnimationListener() {

                    @Override
public void onAnimationStart(Animation animation) {
                    }

                    @Override
public void onAnimationRepeat(Animation animation) {
                        // TODO Auto-generated method stub
                    }

@Override
public void onAnimationEnd(Animation animation) {

Log.v("hari", "--------onAnimationEnd--------");

RelativeLayout.LayoutParams relativeNew 
  = new    RelativeLayout.LayoutParams(
 LayoutParams.WRAP_CONTENT,
  LayoutParams.WRAP_CONTENT);
          relativeNew.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
         relativeNew.addRule(RelativeLayout.ALIGN_LEFT);
     relativeNew.setMargins(125, 10, 10, 10);
    view.setLayoutParams(relativeNew);

 }

这篇关于如何编写动画后视图的onclick监听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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