Code example for ImageView.ScaleType

Methods: ordinal

0
        mMatrix.reset();
 
        final int bWidth = bitmap.getWidth();
        final int bHeight = bitmap.getHeight();
 
        switch (mScaleType) {
 
            case CENTER_CROP: {
                // Center and scale the bitmap so that it entirely fills the 
                // given space. The bitmap ratio remains unchanged 
                float scale;
                float dx = 0, dy = 0;
 
                if (bWidth * mHeight > mWidth * bHeight) {
                    scale = (float) mHeight / (float) bHeight;
                    dx = (mWidth - bWidth * scale) * 0.5f;
                } else { 
                    scale = (float) mWidth / (float) bWidth;
                    dy = (mHeight - bHeight * scale) * 0.5f;
                }