1

I'm almost done finalizing my first app (live wallpaper) for Android.

The live wallpaper works in portrait mode, but when it gets rotated to landscape the background will be in the left and I only see a square in the left corner. In other words the canvas stays portrait even when the screen gets rotated to landscape.

I use a bitmap as a background:

Canvas cb = new Canvas(); 
cb.setBitmap(Achtergrond);

How can I rotate the bitmap 90 degrees and then set the bitmap so it will be shown in landscape? Now the bitmap does not rotate with the screen orientation.

Waynn Lue
  • 11,344
  • 8
  • 51
  • 76
Mars
  • 107
  • 1
  • 13

1 Answers1

1

Easiest is to actually rotate the Canvas underneath it, then draw the bitmap to the canvas, and then rotate the canvas back. Just call Canvas.rotate().

To rotate the bitmap itself, use a matrix, as in this question.

Community
  • 1
  • 1
Steve Blackwell
  • 5,904
  • 32
  • 49
  • Hi Steve thanks for your answer. I tried it but I must load the bitmap and rotate it before calling canvas.setbitmap(); – Mars Mar 10 '12 at 11:38