Image click after animation

2019-08-15 08:51发布

I have this strange issue. I have an image which I rotate about a fixed point using rotateAnimation.

I have handled the click event when the user clicks the images as shown below:

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.imageView1:
        finish();
        Intent i = new Intent(this, Next.class);
        startActivity(i);
        break;
        }
}

The problem I face is that, after I rotate the image, the click event is not triggered when I click the image, but is triggered when I click the position where the image was at first.

I know I must be missing something basic here but I can't figure it out.

1条回答
一纸荒年 Trace。
2楼-- · 2019-08-15 09:05

Animations do not cause the animating View to change position or size. They only show such transformations without affecting any of the properties of the View. Hence the behavior seen by you.

In case you want to actually move/resize the View object, implement AnimationListener and perform the operation on onAnimationEnd.

查看更多
登录 后发表回答