Skip to content Skip to sidebar Skip to footer

Android Add Text To Picture And Save

I want to place a Textiew to my picture and save it, but I'm not sure how to insert the text into the picture. I can attach an image on my picture save it, and it works but now I w

Solution 1:

If you just want "text", and not necessarily a TextView, you can draw text directly on the Canvas using drawText().

Just change it to something like:

  Canvas canvas = new Canvas(newImage);
  canvas.drawBitmap(cameraBitmap, 0f, 0f, null);
  canvas.drawText("some text here", x, y, myPaint);

  ...

  newImage.compress(Bitmap.CompressFormat.JPEG, 80, out);

If you need it to be a TextView for sure, you can convert the view to a bitmap, then draw it on the canvas with drawBitmap(). See this answer for an example of how to convert it.

Post a Comment for "Android Add Text To Picture And Save"