imageView2 = (ImageView) findViewById(R.id.img2); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); //创建一个与bitmap一样大小的bitmap2 Bitmap bitmap2 = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig()); Canvas canvas = new Canvas(bitmap2); //主要以这个对象调用旋转方法 Matrix matrix = new Matrix(); //以图片中心作为旋转中心,旋转180° matrix.setRotate(180, bitmap2.getWidth() / 2, bitmap2.getHeight() / 2); Paint paint = new Paint(); //设置抗锯齿,防止过多的失真 paint.setAntiAlias(true); canvas.drawBitmap(bitmap, matrix, paint); //将旋转后的图片设置到界面上 imageView2.setImageBitmap(bitmap2);