3
不推荐使用BitmapDrawable替代
我有以下代码,将可绘制对象旋转一定程度的角度。 public Drawable rotateDrawable(float angle, Context context) { Bitmap arrowBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.generic2rb); // Create blank bitmap of equal size Bitmap canvasBitmap = arrowBitmap.copy(Bitmap.Config.ARGB_8888, true); canvasBitmap.eraseColor(0x00000000); // Create canvas Canvas canvas = new Canvas(canvasBitmap); // Create rotation matrix Matrix rotateMatrix = new Matrix(); rotateMatrix.setRotate(angle, canvas.getWidth()/2, canvas.getHeight()/2); //Draw bitmap onto canvas …