Hi,
I want to save(export) contents of MyView, which extends TextView, into a bitmap.
I followed the code: [this][1].
It works fine when the size of the text is small.
But when there are lots of texts, and some of the content is out of the screen, what I got is only what showed in the screen.
Then I add a "layout" in my code:
private class MyView extends TextView{
public MyView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public Bitmap export(){
Layout l = getLayout();
int width = l.getWidth() + getPaddingLeft() + getPaddingRight();
int height = l.getHeight() + getPaddingTop() + getPaddingBottom();
Bitmap viewBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(viewBitmap);
setCursorVisible(false);
layout(0, 0, width, height);
draw(canvas);
setCursorVisible(true);
return viewBitmap;
}
}
Now the strange thing happened:
The first time I invoke "export"(I use an option key to do that), I got contents only on the screen.
When I invoke "export" again, I got complete contents, including those out of the screen.
Why?
How to "export" a view, including contents cannot be showed on the screen?
Thank you!
[1]: http://www.techjini.com/blog/2010/02/10/quicktip-how-to-convert-a-view-to-an-image-android/ this