0

所以,基本上我有下一段代码:

  llPhotoTest.setDrawingCacheEnabled(false);
  llPhotoTest.setDrawingCacheEnabled(true);
  ... 
  llPhotoTest.getDrawingCache();

第一次一切正常,但第二次缓存的图片保持不变。我已经看到了很多解决这个问题的方法,但对我来说没有任何效果。我将不胜感激任何帮助或建议。先感谢您

我试过了:

llPhotoTest.setDrawingCacheEnabled(true);
llPhotoTest.getDrawingCache();
llPhotoTest.setDrawingCacheEnabled(false);

我也试过

llPhotoTest.buildDrawingCache();
llPhotoTest.getDrawingCache();
llPhotoTest.destroyDrawingCache();

还是一样的图片:(

有一个布局边界 在此处输入图像描述

4

2 回答 2

2

谢谢大家!我找到了解决方案,这是一个问题。 llPhotoTest.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

从文档http://developer.android.com/reference/android/view/View.html#LAYER_TYPE_SOFTWARE

Indicates that the view has a software layer. A software layer is backed by a bitmap and causes the view to be rendered using Android's software rendering pipeline, even if hardware acceleration is enabled.

于 2015-06-17T13:29:08.493 回答
0

这不是显示位图的好方法。

使用 a ImageView,而不是 aLinearLayout和调用ImageView.setImageBitmap(Bitmap bm)

于 2015-06-17T11:39:20.587 回答