I have the following gradient (generated dynamically):
GradientDrawable dynamicDrawable = new GradientDrawable();
dynamicDrawable.setGradientType(Gra
I finally found the solution from your response. I paste the code for someone could need it:
private Bitmap createDynamicGradient(String color) {
int colors[] = new int[3];
colors[0] = Color.parseColor(color);
colors[1] = Color.parseColor("#123456");
colors[2] = Color.parseColor("#123456");
LinearGradient gradient = new LinearGradient(0, 0, 0, 400, Color.RED, Color.TRANSPARENT, Shader.TileMode.CLAMP);
Paint p = new Paint();
p.setDither(true);
p.setShader(gradient);
Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawRect(new RectF(0, 0, getWidth(), getHeight()), p);
return bitmap;
}