Note that there are some explanatory texts on larger screens.

plurals
  1. POBitmap not zooming only dragging is happening please help me to attain zoomin and zoomout
    primarykey
    data
    text
    <p>hi am new to android platform in my code only dragging is happening and zooming not occurs please help me </p> <p>here is the code that am using</p> <pre><code>@Override public void onDraw(Canvas canvas) { // TODO Auto-generated method stub canvas.drawBitmap(image, getBounds().left,getBounds().top, new Paint()); } /* (non-Javadoc) * @see com.simplogics.surfaceview.Views.BaseView#onTouchEvent(android.view.MotionEvent) */ static final int NONE = 0; static final int DRAG = 1; static final int ZOOM = 2; int mode = NONE; @Override public boolean onTouchEvent(MotionEvent event) { boolean handled = false; Log.d("SimpEditText", "(int)event.getX() " + (int)event.getX()); Log.d("SimpEditText", "(int)event.getY() " + (int)event.getY()); if(isTouchedInBounds((int)event.getX(), (int)event.getY())){ Log.d("SimpEditText", "Touched in Bounds"); handled = true; switch (event.getAction() &amp; MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: savedMatrix.set(matrix); start.set(event.getX(), event.getY()); lastPosition.x = getBounds().left; lastPosition.y = getBounds().top; // initialRotation = rotation(event); Log.d("VerticalLabelView", "mode=DRAG"); mode = DRAG; break; case MotionEvent.ACTION_POINTER_DOWN: mode = ZOOM; initialScale = spacing(event); midPoint(mid, event); Log.d("VerticalLabelView", "mode=ZOOM"); initialRotation = rotation(event); break; case MotionEvent.ACTION_UP: mode = NONE; break; case MotionEvent.ACTION_POINTER_UP: mode = NONE; Log.d("VerticalLabelView", "mode=NONE"); break; case MotionEvent.ACTION_MOVE: if (mode == DRAG) { int x = (int)(event.getX() - start.x); int y = (int)(event.getY() - start.y); setPosition((int)lastPosition.x + x, (int)lastPosition.y + y); }else if(mode == ZOOM){ currentScale = spacing(event); float scale =currentScale/initialScale; currentRotation = rotation(event); float angle = currentRotation - initialRotation; if(getImage().getWidth()&gt; 100 &amp;&amp; image.getWidth() &lt;900){ /*Matrix testMatrix = new Matrix(); testMatrix.postScale(scale, scale,mid.x,mid.y);*/ /* rotatedImage = Bitmap.createBitmap(getImage(), 0, 0, (int)(image.getWidth()*scale), (int)(image.getHeight()*scale), testMatrix, true); */ rotatedImage = Bitmap.createScaledBitmap(getImage(), (int)(image.getWidth()*scale), (int)(image.getHeight()*scale), true); setScale(getBounds().left,getBounds().top , (int)(getImage().getWidth()*scale), (int)(getImage().getHeight()*scale)); /*rotatedImage =rotate(angle, image); Matrix testMatrix = new Matrix(); testMatrix.postScale(scale, scale,mid.x,mid.y); this.image = rotatedImage; rotatedImage = Bitmap.createScaledBitmap(image, (int)(image.getWidth()*scale), (int)(image.getHeight()*scale), true); this.image = rotatedImage;*/ /*Matrix testMatrix = new Matrix(); testMatrix.postScale(scale, scale,mid.x,mid.y);*/ // this.image = rotatedImage; /*rotatedImage = Bitmap.createScaledBitmap(image, (int)(image.getWidth()*scale), (int)(image.getHeight()*scale), true); this.image = rotatedImage;*/ } this.image = rotatedImage; } break; } } return handled; } </code></pre> <p>this is the onDraw and touchevent methods that i used</p> <p>please help me...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload