Code example for Canvas

Methods: drawBitmap, getHeight, getWidth

0
        } 
 
        @Override 
        public void draw(Canvas canvas) {
            if (mBitmap == null) return;
            int width = canvas.getWidth();
            int height = canvas.getHeight();
            int x = (width - mIntrinsicWidth) / 2;
            int y = (height - mIntrinsicHeight) / 2;
            canvas.drawBitmap(mBitmap, x, y, null);
        } 
 
        @Override 
        public int getOpacity() { 
            return android.graphics.PixelFormat.OPAQUE;
        } 
 
        @Override 
        public void setAlpha(int alpha) {
            // Ignore 
        }