Adding text to ImageView in Android

Viewed 166931

I want to use an ImageView to show some message in a fancy way.

How do I add text to an ImageView?

9 Answers

To draw text directly on canvas do the following:

  1. Create a member Paint object in myImageView constructor

    Paint mTextPaint = new Paint();
    
  2. Use canvas.drawText in your myImageView.onDraw() method:

    canvas.drawText("My fancy text", xpos, ypos, mTextPaint);
    

Explore Paint and Canvas class documentation to add fancy effects.

Related