1
我在ImageView上繪製一個小圖標(用於繪製小圖塊),該圖標使用縮放縮放進行縮放。滾動主ImageView的這樣的時候我可以移動圖標:在ImageView上移動一個點(xx,yy)相對於ImageView的縮放縮放
public boolean onTouch(View v, MotionEvent event) {
case MotionEvent.ACTION_MOVE:
if (mode == Util.DRAG) {
//this scrolls image view
matrix.set(savedMatrix);
matrix.postTranslate(event.getX() - start.x, event.getY() - start.y);
..
..
//
int xx = (int) (event.getX() - start.x);
int yy = (int) (event.getY() - start.y);
xx = (Icon.xpos + xx);
xx = (Icon.ypos + yy);
Icon.drawViewOnScreen(xx , yy);
}else if(mode == ZOOM){ //pinch zoom
float newDist = spacing(event);
if (newDist > 10f && ((newDist - oldDist) > 10f || (oldDist - newDist) > 10f)) {
matrix.set(savedMatrix);
float scale = newDist/oldDist;
matrix.getValues(matrixValues);
float currentScale = matrixValues[Matrix.MSCALE_X];
scale = .65f/currentScale;
matrix.postScale(scale, scale, Util.screenWidth/2, Util.screenHeight/2);
Icon.drawViewOnScreen(Icon.xpos+scale, Icon.ypos+scale); **// This gets icon away from its orignal location. I need to make it stay on same map tile which needs actually adjusting
its position with respect to scale. I have attached a sample image to express**
}}
image.setImageMatrix(matrix);
我們應該添加到XX和YY圖標的每次通話掐,以便它可以更新其對ImageView的位置相對於標什麼因素?
思考,請...