Android 我想绕着它的中心旋转。在写入可绘制的文本之前
我有一张可抽的支票。我想先围绕它的中心旋转,然后再在drawable上写入文本Android 我想绕着它的中心旋转。在写入可绘制的文本之前,android,Android,我有一张可抽的支票。我想先围绕它的中心旋转,然后再在drawable上写入文本 drawable= this.getResources().getDrawable(R.drawable.image); final int IMAGE_WIDTH = drawable.getIntrinsicWidth(); final int IMAGE_HEIGHT = drawable.getIntrinsicHeight(); Bitmap bitmap = Bitmap.createBitmap(IM
drawable= this.getResources().getDrawable(R.drawable.image);
final int IMAGE_WIDTH = drawable.getIntrinsicWidth();
final int IMAGE_HEIGHT = drawable.getIntrinsicHeight();
Bitmap bitmap = Bitmap.createBitmap(IMAGE_WIDTH,
IMAGE_HEIGHT,
Bitmap.Config.ARGB_8888);
Canvas imageCanvas = new Canvas(bitmap);
Paint imagePaint = new Paint();
imagePaint.setTextAlign(Align.CENTER);
imagePaint.setTextSize(16f);
drawable.draw(imageCanvas);
imageCanvas.drawText("",
IMAGE_WIDTH / 2,
(IMAGE_HEIGHT - imagePaint.ascent()) / 2,
imagePaint);
LayerDrawable finalImage = new LayerDrawable(
new Drawable[]{drawable, new BitmapDrawable(bitmap)});
您可以使用来执行所有轮换游戏,然后将其设置为您的 最好的方法是查看动画。 我找到了解决办法
Bitmap bmpOriginal = BitmapFactory.decodeResource(this.getResources(), R.drawable.image);
final int IMAGE_WIDTH = drawable.getIntrinsicWidth();
final int IMAGE_HEIGHT = drawable.getIntrinsicHeight();
Matrix matrix = new Matrix();
matrix.postRotate(rotate);
Bitmap resizedBitmap = Bitmap.createBitmap(bmpOriginal, 0, 0,width, height, matrix, true);
Canvas imageCanvas = new Canvas(resizedBitmap);
BitmapDrawable bmd = new BitmapDrawable(resizedBitmap);
Paint imagePaint = new Paint();
imagePaint.setTextAlign(Align.CENTER);
imagePaint.setTextSize(14f);
bmd.draw(imageCanvas);
imageCanvas.drawText("Text",
IMAGE_WIDTH / 2,
(IMAGE_HEIGHT - imagePaint.ascent()) / 2,
imagePaint);
LayerDrawable finalImage = new LayerDrawable(
new Drawable[]{bmd, new BitmapDrawable(resizedBitmap)});
你想旋转什么?一个来自资源的图像?也许你可以这样做