安卓得到充分的显示为位图位图、充分

2023-09-06 21:50:17 作者:敬往事一杯酒

可能重复:   Android 2.1查看的getDrawingCache()方法总是返回null

我哈瓦,我要保存一个位图的布局。

I hava a Layout which I want to save an bitmap.

如果我的布局比屏幕较小的一切是好的。但是,如果我的布局比较大,位图(b)为空。

If my Layout is smaller than the screen everything is fine. But if my Layout is bigger, the bitmap (b) is null.

这是我的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?

推荐答案

buildDrawingCache不应该有你的看法,如果它是大于屏幕视图的可见部分只绘制,只有高速缓存保存什么画。

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.

您可以试试这个方法。这里的位图传递给视图,使得该视图drawon到该位图。 http://www.brighthub.com/mobile/google-android/articles /30676.aspx

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