【发布时间】:2018-09-11 20:59:25
【问题描述】:
我需要将渐变颜色动态应用到将在另一个位图上绘制的位图(它看起来像带有一些透明部分的划痕):this is the result i need。
这是我的代码:
Bitmap bitmapbackground = bitmaporiginal.copy(bitmaporiginal.getConfig(), true);
Bitmap bitmaptocolor = BitmapFactory.decodeResource(activity.getResources(), R.drawable.scratch);
LinearGradient gradient = new LinearGradient(0, 0, 0, bitmaptocolor.getHeight(), Color.parseColor("#D81B60"), Color.parseColor("#F48FB1"), Shader.TileMode.CLAMP);
Paint paint = new Paint();
paint.setShader(gradient);
Canvas canvas = new Canvas(bitmapbackground);
canvas.drawBitmap(bitmaptocolor, 0, 0, paint);
但是通过这种方式,它不会将渐变颜色应用于划痕(它始终保持黑色)。我做错了什么?
【问题讨论】:
标签: android colors bitmap gradient