Code example for Matrix

Methods: getValuespostScalesetsetScale

0
			// 若为ZOOM模式,则多点触摸缩放 
			else if (mode == ZOOM) {
				float newDist = spacing(event);
				//Log.d(TAG, "newDist=" + newDist); 
				if (newDist > 10f) {
					matrix.set(savedMatrix);
					float scale = newDist / oldDist;
					// 设置缩放比例和图片中点位置 
					matrix.postScale(scale, scale, mid.x, mid.y);
				} 
			} 
			break; 
		} 
 
		// Perform the transformation 
		imgView.setImageMatrix(matrix);
		CheckView(); 
		return true; // indicate event was handled 
	} 
 
    /** 
     * 限制最大最小缩放比例,自动居中 
     */ 
    private void CheckView() { 
        float p[] = new float[9];
        matrix.getValues(p);
        if (mode == ZOOM) {
            if (p[0] < minScaleR) {
                matrix.setScale(minScaleR, minScaleR);
            } 
            if (p[0] > MAX_SCALE) {
                matrix.set(savedMatrix);
            } 
        } 
        center(); 
    } 
 
Stop searching for code, let great code find you!  Add Codota to your java IDE