Android get full View as Bitmap [duplicate]
Asked Answered
L

1

2

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?

Lias answered 9/10, 2011 at 11:39 Comment(2)
Have you also done buildDrawingCache()?Domination
My problem is not that I always get null, just when my layout is larger than the screen. An yes, i already tried buildDrawingCache() and got the same :-(Lias
F
2

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

Forcefeed answered 9/10, 2011 at 13:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.