TranslateAnimated ImageView的不可点击的动画完成后,[机器人] [英] TranslateAnimated ImageView not clickable after animation [Android]

查看:163
本文介绍了TranslateAnimated ImageView的不可点击的动画完成后,[机器人]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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);
        }
        });

这篇关于TranslateAnimated ImageView的不可点击的动画完成后,[机器人]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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