问题
Possible Duplicate:
Android 2.1 View's getDrawingCache() method always returns null
I hava a Layout which I want to save an bitmap.
If my Layout is smaller than the screen everything is fine. But if my Layout is bigger, the bitmap (b) is null.
This is my code:
layout.setDrawingCacheEnabled(true);
int wt = layout.getMeasuredWidth();
int ht = layout.getMeasuredHeight();
layout.layout(0, 0, wt, ht);
Bitmap b = layout.getDrawingCache(true);
So how can I get the whole View as an Bitmap?
回答1:
buildDrawingCache should not have your view if it is bigger than the screen as the visible portion of the view is only drawn and the cache holds only what is drawn.
You may try this method. Here a bitmap is passed to the view, so that the view is drawon to the bitmap. http://www.brighthub.com/mobile/google-android/articles/30676.aspx
来源:https://stackoverflow.com/questions/7703227/android-get-full-view-as-bitmap