Example usage for android.graphics.drawable NinePatchDrawable draw

List of usage examples for android.graphics.drawable NinePatchDrawable draw

Introduction

In this page you can find the example usage for android.graphics.drawable NinePatchDrawable draw.

Prototype

@Override
    public void draw(Canvas canvas) 

Source Link

Usage

From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.draggable.DraggingItemDecorator.java

private Bitmap createDraggingItemImage(View v, NinePatchDrawable shadow) {
    int width = v.getWidth() + mShadowPadding.left + mShadowPadding.right;
    int height = v.getHeight() + mShadowPadding.top + mShadowPadding.bottom;

    final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    final Canvas canvas = new Canvas(bitmap);

    if (shadow != null) {
        shadow.setBounds(0, 0, width, height);
        shadow.draw(canvas);
    }//  w  w w .j a  va 2 s .c  om

    final int savedCount = canvas.save(Canvas.CLIP_SAVE_FLAG | Canvas.MATRIX_SAVE_FLAG);
    // NOTE: Explicitly set clipping rect. This is required on Gingerbread.
    canvas.clipRect(mShadowPadding.left, mShadowPadding.top, width - mShadowPadding.right,
            height - mShadowPadding.bottom);
    canvas.translate(mShadowPadding.left, mShadowPadding.top);
    v.draw(canvas);
    canvas.restoreToCount(savedCount);

    return bitmap;
}