安卓得到充分的显示为位图 [英] Android get full View as Bitmap

查看:107
本文介绍了安卓得到充分的显示为位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/2817166/android-2-1-views-getdrawingcache-method-always-returns-null">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

这篇关于安卓得到充分的显示为位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆