Code example for Matrix

Methods: postConcat, postScale, postTranslate, reset

        float viewWidth = getWidth();
        float viewHeight = getHeight();
        float w = bitmap.getWidth();
        float h = bitmap.getHeight();
        // We limit up-scaling to 2x otherwise the result may look bad if it's 
        // a small icon. 
        float widthScale = Math.min(viewWidth / w, 2.0f);
        float heightScale = Math.min(viewHeight / h, 2.0f);
        float scale = Math.min(widthScale, heightScale);
        matrix.postScale(scale, scale);
        matrix.postTranslate((viewWidth - w * scale) / 2F, (viewHeight - h * scale) / 2F);
    // Combine the base matrix and the supp matrix to make the final matrix. 
    protected Matrix getImageViewMatrix() {
        // The final matrix is computed as the concatentation of the base matrix