DJafari
DJafari

Reputation: 13535

write text on image and show it to a imageview

i write text on a picture with this code :

Bitmap mBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.file);
Canvas g = new Canvas(mBitmap);
Paint p = new Paint();
p.setColor(Color.BLACK);
p.setAntiAlias(true);
g.drawText("Text", 10, 10, p);

How can i show result in a imageview ?

thanks

Upvotes: 2

Views: 1788

Answers (1)

Dalmas
Dalmas

Reputation: 26547

Create an ImageView (if you don't have one in your layout), and use setImageDrawable() :

    ImageView image = new ImageView(this); 
    image.setImageDrawable(new BitmapDrawable(mBitmap));

Then add your ImageView to your layout with addView().

Upvotes: 1

Related Questions