TranslateAnimated ImageView的不可点击的动画完成后,[机器人]机器人、动画、完成后、TranslateAnimated

由网友(凹凸突显回忆)分享简介:我有2 的ImageView s表示我从屏幕底部的顶部翻译。这些观点都是从XML infalted和动画是从Java code补充说。动画作品完美,但 onClickListener 我说在java中code似乎并没有工作。我用 fillAfter 动画,使iamges停留在翻译后,他们的到来,但这些图片不是再点击属...

我有2 的ImageView s表示我从屏幕底部的顶部翻译。这些观点都是从XML infalted和动画是从Java code补充说。动画作品完美,但 onClickListener 我说在java中code似乎并没有工作。我用 fillAfter 动画,使iamges停留在翻译后,他们的到来,但这些图片不是再点击属性。不过,翻译的遗体前,他们的立场点击... 我看不到这个逻辑。任何人都可以给我一些忠告的?

I have 2 ImageViews that I translate from the top of the screen to the bottom. these views are infalted from xml and the animation is added from java code. The animation works perfectly, but the onClickListener I added in java code doesn't seem to work. I used fillAfter attribute of the animation to make the iamges stay at their arrival after the translation, but THESE images aren't clickable anymore... However, their position before translation remains clickable... I can't see the logic of this. Could anyone give me some piece of advice about that?

推荐答案

这是因为动画会影响部件的只是图纸。然而,真正的位置不受影响 - 它仍然是在previous 1 -

This is because Animations affects only the drawing of widget. However, The real Location is not affected -It is still in the previous one-.

要解决这个问题,你需要手动通过安装监听器的动画更新的ImageView的布局参数如下:

To overcome this problem, you need to update the layout parameters of the ImageView manually by installing an animation listener as follows:

Animation.setAnimationListener(new AnimationListener() {
        public void onAnimationStart(Animation arg0) {

        }

        public void onAnimationRepeat(Animation arg0) {
            //TODO Auto-generated method stub
        }

        public void onAnimationEnd(Animation arg0) {
            android.widget.LinearLayout.LayoutParams params = new LayoutParams(
            android.widget.LinearLayout.LayoutParams.FILL_PARENT,
            android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
            params.topMargin = addLocationButton.getTop()-100;

            ImageView.setLayoutParams(params);
        }
        });
阅读全文

相关推荐

最新文章