Android, what should be the pivot point for rotating the image around its center of base

Please read the entire question carefully before marking duplication or closing it.

I want to rotate the image (especially the arrow image ) around its center point of the base.

eg. When I start, my image will be like a second hand in the clock by 9. And suppose that if I rotate this image 30 degrees, it should look like the second hand of the stopwatch by 10, and if it is 120 degrees, then the second hand by 1.

So, I want to rotate this image around it in the center (along the x axis) of the base.

So, what should I pass as a rotation (X and Y) if I code first

imageView.setPivotX(1f);
            imageView.setPivotY(1f);
            imageView.setRotation(-30);

or second code

Matrix matrix = new Matrix();
    imageView.setScaleType(ScaleType.MATRIX);
    matrix.postRotate((float) 20, 0f, 0f);
    imageView.setImageMatrix(matrix);

or third code

Bitmap myImg = BitmapFactory.decodeResource(getResources(), R.drawable.arrow_0_degree);
    Matrix matrix = new Matrix();
    matrix.postRotate(30);
    Bitmap rotated = Bitmap.createBitmap(myImg, 0, 1, myImg.getWidth(), myImg.getHeight(), matrix, true);
    imageView.setImageBitmap(rotated);

or fourth code

final RotateAnimation rotateAnim = new RotateAnimation(0.0f, degree,
        RotateAnimation.RELATIVE_TO_SELF, 0.5f,
        RotateAnimation.RELATIVE_TO_SELF, 0.5f);

rotateAnim.setDuration(0);
rotateAnim.setFillAfter(true);
imgview.startAnimation(rotateAnim);

, 90 .

, Google .

. enter image description here

+4
1

^^

:

    final RotateAnimation rotateAnim = new RotateAnimation(0.0f, 30,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 1f);
    rotateAnim.setDuration(0);
    rotateAnim.setFillAfter(true);
    mImageView.setAnimation(rotateAnim);
    rotateAnim.start();
+9

All Articles