0

I have an ImageView which is animated via startAnimation() to slide it into the screen. It is visible and enabled in the XML. When I add a Handler for a delay or an onClick event, nothing happens. When I remove the startAnimation() everything works fine. Except the animation of course.

Heres my code:

balloon.setOnClickListener(new OnClickListener() {
   @Override
    public void onClick(View view) {
       view.setVisibility(View.GONE);
    }
});

Animation dropDown = 
   AnimationUtils.loadAnimation(context, R.anim.balloon_slide_down);
dropDown.setStartOffset(1500);

balloon.startAnimation(dropDown);

Any ideas why that is? I'm quite frustrated by now...

Thanks,

Ron

Ron
  • 22,128
  • 31
  • 108
  • 206

3 Answers3

0

Your ImageView probably isn't in the location you think it is. Try setting the offset on the ImageView before the animation.

balloon.offsetTopAndBottom(offset);
//Start Animation from -offset
baconcheese113
  • 843
  • 2
  • 13
  • 27
0

The animation only give you an animation that the imageview will be slided but actually the position of the imageview isn't changed

if you want to change it you can move it using layoutparams with looping it in a UIthread

Niko Adrianus Yuwono
  • 11,012
  • 8
  • 42
  • 64
  • but without the animation the position of the view is the same as after the animation. so it should work, shouldn't it? – Ron Nov 12 '12 at 20:52
0

Alright... I thought it was odd that the ÌmageView should not be at the position it is shown. So I figured out that just the setVisibility() is somehow not working.

I changed my code to the following and it works:

balloon.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View view) {
           ((ViewGroup) balloon.getParent()).removeView(balloon);
      }
});
Ron
  • 22,128
  • 31
  • 108
  • 206