Android examples for Graphics:Canvas
draw Bitmap Center on Canvas
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; public class Main { public static void drawBitmapCenter(Canvas canvas, float f, float f1, float f2, Bitmap bitmap, Paint paint) { drawBitmapCenter(canvas, f, f1, f2, true, true, bitmap, paint); }/* w w w. j a v a2 s .c o m*/ public static void drawBitmapCenter(Canvas canvas, float f, float f1, float f2, boolean flag, boolean flag1, Bitmap bitmap, Paint paint) { if (flag) { f -= (f2 * (float) bitmap.getWidth()) / 2.0F; } if (flag1) { f1 -= (f2 * (float) bitmap.getHeight()) / 2.0F; } Matrix matrix = new Matrix(); matrix.setScale(f2, f2); matrix.postTranslate(f, f1); canvas.drawBitmap(bitmap, matrix, paint); } }