Android中视图的水印效果

时间:2015-08-03 21:52:12

标签: android watermark

我正在开发一个Android应用程序,我需要为多行的EditText添加水印效果(图像)。实现这一目标的最佳方法是什么?

1 个答案:

答案 0 :(得分:0)

Here是一个关于android图像处理的精彩教程。以下是网站的源代码

public static Bitmap mark(Bitmap src, String watermark, Point location, Color color, int alpha, int size, boolean underline) {
int w = src.getWidth();
int h = src.getHeight();
Bitmap result = Bitmap.createBitmap(w, h, src.getConfig());

Canvas canvas = new Canvas(result);
canvas.drawBitmap(src, 0, 0, null);

Paint paint = new Paint();
paint.setColor(color);
paint.setAlpha(alpha);
paint.setTextSize(size);
paint.setAntiAlias(true);
paint.setUnderlineText(underline);
canvas.drawText(watermark, location.x, location.y, paint);

return result;
}