Rotating an ImageVIew along with its original position in android in below HoneyComb versions

Posted by candy on Stack Overflow See other posts from Stack Overflow or by candy
Published on 2012-11-07T10:53:24Z Indexed on 2012/11/07 11:00 UTC
Read the original article Hit count: 253

I am trying rotate an ImageView along with its original location (rotating the image aswell as the view). So that After rotation, when I click on the rotated Image in its current position, it should be able clicked in the rotated location only.

For this solution I am trying the following code. However it is rotating is going fine. After the rotation end I need to place the ImageView and Image in the rotated Location to make it able click over there only. But it is not going successfully. I am unable to rotated Image location axis points to place correctly. Can any one please suggest a way to resolve this issue.

fyi-It should work on Gingerbread version android-9

 aniView1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e("", "Clicked on IMAGE VIEW - 1");
            }
        });

        RotateAnimation rotate5 = new RotateAnimation(0, 150,
                Animation.INFINITE, 100, Animation.INFINITE, 250);
        //rotate5.setFillAfter(true);
        rotate5.setDuration(2000);
        rotate5.setInterpolator(new LinearInterpolator());
        aniView1.setAnimation(rotate5);

        rotate5.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {

                int newTop = (int) (aniView1.getTop() + aniView1.getWidth());

                aniView1.layout(aniView1.getLeft()-200, newTop,
                        aniView1.getRight(),
                        aniView1.getBottom() + aniView1.getMeasuredWidth());

                // aniView1.setLayoutParams(new
                // RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT));

            }
        });

© Stack Overflow or respective owner

Related posts about android

Related posts about animation