Rotate the image around its center without cropping its edges

I adjusted the image, but it was just rotated by its bitmap, and not the whole view. I don’t want to use animation because I am dragging and dropping the image so that the moving animated results of the image look strange, so sticking to onDraw/draw, plus overriding a draw does nothing special.

        @Override
        protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
        canvas.save();
        canvas.rotate(rotationAngle, rotationW, rotationH);
        super.onDraw(canvas);
        canvas.restore();
        }    

how can i rotate the whole view not only its bitmap?

+5
source share
3 answers
  • It is necessary to check the width and height of the image if the height> width, and during the width of the rotation should be equal to the height and the same height.

  • fill_parent, // .

+1

,

Android: clipChildren = ""

ViewGroup draw onDraw

.

+3

API 11, :

.setRotation(float angle);

http://developer.android.com/reference/android/view/View.html#attr_android:rotation


API 11 :

@Override
protected void onDraw(Canvas c) {
  c.save();
  c.rotate(...);
  super.onDraw(c);
  c.restore();
}
0

All Articles