getDrawingCache()总是返回null [英] getDrawingCache() always returning null

查看:960
本文介绍了getDrawingCache()总是返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想捕捉的ImageView的内容通过DrawingCache。我写了下面code。

I want to capture The content of ImageView by using DrawingCache. I written the below code.

iv1 = (ImageView)findViewById(R.id.iv1);
iv2 = (ImageView)findViewById(R.id.iv2);            
iv1.setDrawingCacheEnabled(true);
Bitmap myScreenshot = iv1.getDrawingCache();
iv2.setImageBitmap(myScreenshot);

不过,我收到只有一个在屏幕上的图像。后来我才知道的 myScreenshot 为null

我看到了关于同样的问题很多帖子,但没有妥善的解决方案。

I saw many posts regarding same problem, but no proper solution.

我认为我们必须在清单中添加任何权限?或者需要root权限来实现这一目标?请帮我有关这个问题。

I thought any permissions we have to add in manifest ? or root permission required to achieve this ? Please help me regarding this problem.

推荐答案

尝试调用 buildDrawingCache() getDrawingCache()

编辑: 呼叫 getDrawingCache()后,页面加载,而不是的onCreate

Call getDrawingCache(), after the page have loaded, instead of onCreate

这篇关于getDrawingCache()总是返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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