在图像上写入文本并将其显示在imageview中

时间:2011-11-26 17:21:21

标签: android

我用这段代码在图片上写文字:

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);

如何在imageview中显示结果?

感谢

1 个答案:

答案 0 :(得分:1)

创建一个ImageView(如果你的布局中没有),并使用setImageDrawable()

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

然后使用addView()将ImageView添加到您的布局中。

相关问题