Android的 - 容器不正确更新的动画动作包含按钮hitboxes [英] Android - Animation movement of container does not correctly update contained buttons hitboxes

查看:165
本文介绍了Android的 - 容器不正确更新的动画动作包含按钮hitboxes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我必须运行在Android 2.2(上HTC渴望)的应用程序。当用户presses菜​​单键,菜单我从silkily顶部和底部滑入。这工作好了。我这样想着。事实证明,即使在ImageButtons是关闭屏幕和看不见的,地方之前,我搬到他们的视线,他们是在hitboxes激活按钮。

So I have an application running on Android 2.2 (on a HTC desire). When the user presses the menu key, my menus silkily slide in from top and bottom. This works just great. Or so I thought. It turns out that even when the ImageButtons are off screen and invisible, the hitboxes of the places where they were before I moved them out of sight activate the buttons.

我曾尝试:

_top_slide_out_menu.forceLayout();
_top_slide_out_menu.recomputeViewAttributes(_measure);
_top_slide_out_menu.computeScroll();

没有区别。在猜测这可能是因为我用的是移动的动画父容器对象,而不是按钮本身。我只能hypothesise有没有更新的孩子hitboxes的错误。
此错误似乎也影响我申请到按钮后续动画。我有一个动画我上的一个按钮,我有$ P $使用不同的动画pviously移动运行。这第二个动画收缩然后生长的按钮,给一个点击的IM pression。只有一半的按钮被重绘,因为这是包含在原始键位置的区域内的一半。

No difference. At a guess it may be because I am moving the parent container object using the animation rather than the buttons themselves. I can only hypothesise that there is a bug that does not update the child hitboxes. This bug seems to also affect subsequent animations I apply to the button. I have a animation I run on a button that I have previously moved using a different animation. This second animation shrinks then grows the button to give the impression of a click. Only half of the button is redrawn, as that is the half contained within the area of the origional button location.

所以现在的问题是,有没有人碰到这个?有什么比单独移动所有的按钮(这将得到相当烦人)?

So the question is, has anyone run into this? Is there anything to try other than moving all the buttons individually (which would get rather tiresome)?

我倒是AP preciate任何想法在这一点!

I'd appreciate any ideas at this point!

感谢

推荐答案

Android的动画只有转移当您添加动画给他们的UI控件的像素。要真正更新动画完成后的布局,应实现动画监听器和手动更新其他明智的布局老布局仍然会留在唯一的像素移位。

Android animations only shifts the pixels of the UI controls when you add animations to them. To actually update the layout after the animation, you should implement an animation listener and manually update the layout other wise the old layout will still remain with the only the pixels shifted.

这篇关于Android的 - 容器不正确更新的动画动作包含按钮hitboxes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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