2

enter image description here

I have layout in that it contain a horizontal scroll scale.

My question is how make this type of zoom effect on the center of the layout? Is it possible? i have draw the scale in canvas and zoom the canvas??

Please help me. Thank's in advance.

ShreeshaDas
  • 2,042
  • 2
  • 17
  • 36
  • first of all draw the scale friend .... zooming is easier – Venkatesh S Jan 19 '13 at 11:57
  • @CaptainAmerica drawing on the canvas is not big issue.issue is how to zoom the scale on canvas?? – ShreeshaDas Jan 19 '13 at 12:01
  • using canvas u can capture location of ur rectangular scale as bitmap so that u can zoom the bitmap easily friend... i had already did this .... – Venkatesh S Jan 19 '13 at 12:04
  • 1
    See this answer, it should do exactly as you require: http://stackoverflow.com/questions/11442934/magnifying-part-of-the-canvas-when-touched/11450800#11450800 – nmw Jan 19 '13 at 12:32

2 Answers2

1

I think you want a Transformation: http://developer.android.com/reference/android/view/animation/Transformation.html

The code in your onDraw method will look something like this:

canvas.save();
transformation.transform(canvas);
drawable.draw(canvas);
canvas.restore();
G. Blake Meike
  • 6,615
  • 3
  • 24
  • 40
0

Step 1: At first draw the scale(drawing) on a canvas.

Step 2: get the zooming region, and apply this region as the clipRegion on the canvas ..

Step 3: get the bitmap from the canvas, and draw it on the canvas applying scale on it,scaling pivot point will be the center point of the area you want to zoom,

Bitmap.Config conf = Bitmap.Config.ARGB_8888; 
Bitmap bitmap_object = Bitmap.createBitmap(width, height, conf); 
Canvas canvas_object = new Canvas(bitmap_object);

/* now  draw your drawing on canvas_object */

Bitmap temp = bitmap_object;

Matrix matrix_object = new Matrix();

/* now set transform and scale on matrix_object to zoom */

Paint paint_object = new Paint();
paint_object.setFilterBitmap(true);

Region reg= /* region of your zooming area */
canvas_object.clipRegion(reg);
canvas_object.drawBitmap(temp,matrix_object,paint_object);
Scarecrow
  • 4,057
  • 3
  • 30
  • 56