Hi Sponge & adamp,
Now I also need to get bitmap from text view, but I failed use the view.draw(Canvas) method.
Here is my code:
class MyView extends View{
......
public MyView(Context context) {
super(context);
mBackDraw = Bitmap.createBitmap(100, 100,
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(mBackDraw);
// TODO Auto-generated constructor stub
mText = new TextView(context);
mText.setText("1 line\n 2line \n \n \n 3fliener");
mText.draw(canvas);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.save();
canvas.drawColor(Color.YELLOW);
canvas.drawBitmap(mBackDraw, 0, 0, PAINT);
canvas.restore();
}
}
This is just a test code.
I create the bitmap "mBackDraw", and draw the textview to it.
Then in the MyView's onDraw method, I draw the bitmap using "canvas.drawBitmap(mBackDraw, 0, 0, PAINT);".
I except that the text view's content should be drawn, but nothing on the screen.
Will you please tell me where I get wrong?
Thanks a lot!!