Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I got a solution for this. But its not seems to be perfect one. Just add the methods given below after the switch cases and just before the <code>view.setImageMatrix(matrix);</code> here is the methods:</p> <pre><code>private void limitZoom(Matrix m) { float[] values = new float[9]; m.getValues(values); float scaleX = values[Matrix.MSCALE_X]; float scaleY = values[Matrix.MSCALE_Y]; if(scaleX &gt; MAX_ZOOM) { scaleX = MAX_ZOOM; } else if(scaleX &lt; MIN_ZOOM) { scaleX = MIN_ZOOM; } if(scaleY &gt; MAX_ZOOM) { scaleY = MAX_ZOOM; } else if(scaleY &lt; MIN_ZOOM) { scaleY = MIN_ZOOM; } values[Matrix.MSCALE_X] = scaleX; values[Matrix.MSCALE_Y] = scaleY; m.setValues(values); } private void limitDrag(Matrix m) { float[] values = new float[9]; m.getValues(values); float transX = values[Matrix.MTRANS_X]; float transY = values[Matrix.MTRANS_Y]; float scaleX = values[Matrix.MSCALE_X]; float scaleY = values[Matrix.MSCALE_Y]; ImageView iv = (ImageView)findViewById(R.id.map); Rect bounds = iv.getDrawable().getBounds(); int viewWidth = getResources().getDisplayMetrics().widthPixels; int viewHeight = getResources().getDisplayMetrics().heightPixels; int width = bounds.right - bounds.left; int height = bounds.bottom - bounds.top; float minX = (-width + 20) * scaleX; float minY = (-height + 20) * scaleY; if(transX &gt; (viewWidth - 20)) { transX = viewWidth - 20; } else if(transX &lt; minX) { transX = minX; } if(transY &gt; (viewHeight - 80)) { transY = viewHeight - 80; } else if(transY &lt; minY) { transY = minY; } values[Matrix.MTRANS_X] = transX; values[Matrix.MTRANS_Y] = transY; m.setValues(values); } </code></pre> <p>Is there is any other solution better than this one?</p>
 

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