I looked through multiple similar questions, although I haven\'t found proper answer on my query.
I have a drawable, defined in shape.xml
Since you want to load a Drawable, not a Bitmap, use this:
Drawable d = getResources().getDrawable(R.drawable.your_drawable, your_app_theme);
To turn it into a Bitmap:
public static Bitmap drawableToBitmap (Drawable drawable) {
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable)drawable).getBitmap();
}
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
}
Taken from: How to convert a Drawable to a Bitmap?