Hi! I found the solution! I did not need to rotate the image. I just had to rotate the canvas-object, I was using. LunarLander has the best example. Here is some code of it:
canvas.save(); canvas.rotate((float) mHeading, (float) mX, mCanvasHeight - (float) mY); if (mMode == STATE_LOSE) { mCrashedImage.setBounds(xLeft, yTop, xLeft + mLanderWidth, yTop + mLanderHeight); mCrashedImage.draw(canvas); } else if (mEngineFiring) { mFiringImage.setBounds(xLeft, yTop, xLeft + mLanderWidth, yTop + mLanderHeight); mFiringImage.draw(canvas); } else { mLanderImage.setBounds(xLeft, yTop, xLeft + mLanderWidth, yTop + mLanderHeight); mLanderImage.draw(canvas); } canvas.restore(); Greetings, Martin On 1 Jan., 19:15, Martin <google-gro...@digle.de> wrote: > HI! > > I have a png-picture in > ImageView rotatedimage = new ImageView () > > Is there a better way to rotate it in changing directions than the > following way? There I have to create a new picture for every new > rotating angle and add it to the layout: > > Bitmap bitmap = BitmapFactory.decodeResource(getResources > (),R.drawable.frosch); > Matrix rotationMatrix = new Matrix(); > rotationMatrix.setRotate(grad); > > Bitmap rotatedbitmap = Bitmap.createBitmap(frogbitmap, 0, 0, > rotatedbitmap.getWidth(), rotatedbitmap.getHeight(), rotationMatrix, > true); > > BitmapDrawable bmd = new BitmapDrawable(rotatedbitmap); > > rotatedimage.setImageDrawable(bmd); > > mtrx.postRotate(10); > rotatedimage.setImageMatrix(mtrx); > > Greetings, Martin -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en