观看动画不会改变触摸区域 [英] View animation doesn't change touch area

查看:115
本文介绍了观看动画不会改变触摸区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个TranslateAnimation后,对视图翻译OnClickListener未翻译。我想在一个定制的LinearLayout但没有成功覆盖getHitRect。我还试图用一个touchdelegate和所有其他的建议,整个互联网上找到没有成功:)

After a TranslateAnimation, the OnClickListener on view translated is not translated. I tried overriding getHitRect in a custom LinearLayout but without success. I also tried to use a touchdelegate and all other suggestions found on the whole internet without success :)

TranslateAnimation open = new TranslateAnimation(0, displayWidth - ivTimelineWidth, 0, 0);
open.setDuration(1000);   
open.setFillAfter(true);
llMapContent.startAnimation(open);

请帮我:)

朱利安

推荐答案

如果我理解正确你的问题,你想它被翻译,它不是注册的东西onTouch后的东西点击。这个问题发生,因为TranslateAnimation实际上并不移动对象,在画面上只的像素。你会调用onTouch如果触摸那里的项目是该地区。要真正移动,而不是屏幕上的像素我建议使用此code片段对象:

If I am understanding your problem correctly, you want to click on something after it's been translated and it's not registering the onTouch of the something. This problem is occurring because TranslateAnimation does not actually move the object, just the pixels on the screen. You would call the onTouch if touch the area where the item was. To actually move the object rather than the pixels on the screen I recommend using this code snippet:

MarginLayoutParams marginParams = new MarginLayoutParams(someobject.getLayoutParams());
marginParams.setMargins(xx, xx, xx, xx);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(marginParams);
someobject.setLayoutParams(layoutParams); 

您也许应该把这个在 onAnimationEnd onAnimationStart 方法。希望这有助于。

You should probably place this in the onAnimationEnd or onAnimationStart methods. Hope this helps.

这篇关于观看动画不会改变触摸区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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