Example usage for android.graphics.drawable VectorDrawable setBounds

List of usage examples for android.graphics.drawable VectorDrawable setBounds

Introduction

In this page you can find the example usage for android.graphics.drawable VectorDrawable setBounds.

Prototype

public void setBounds(int left, int top, int right, int bottom) 

Source Link

Document

Specify a bounding rectangle for the Drawable.

Usage

From source file:com.github.topbottomsnackbar.TBSnackbar.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static Bitmap getBitmap(VectorDrawable vectorDrawable) {
    Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight(),
            Bitmap.Config.ARGB_8888);/*  ww w.  j a  v  a  2  s.c o  m*/
    Canvas canvas = new Canvas(bitmap);
    vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    vectorDrawable.draw(canvas);
    return bitmap;
}