I have the following gradient (generated dynamically):
GradientDrawable dynamicDrawable = new GradientDrawable();
dynamicDrawable.setGradientType(Gra
You can use below code mention in: Android: Convert Drawable to Bitmap
public Bitmap convertToBitmap(Drawable drawable, int widthPixels, int heightPixels) {
Bitmap mutableBitmap = Bitmap.createBitmap(widthPixels, heightPixels, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(mutableBitmap);
drawable.setBounds(0, 0, widthPixels, heightPixels);
drawable.draw(canvas);
return mutableBitmap;
}