问题描述
- 关于安卓bitmap问题,困扰了好久
-
代码如图,我想用gallery显示bitmap出来,可是显示的图片都是一样的,为什么呢,如果说是bitmap内存没释放,我用recyle方法时候程序会闪退。求解答开发-关于安卓bitmap问题,困扰了好久-安卓开发bitmap">
解决方案
public void GetBMP(){
LinearLayout contentLayout;
contentLayout = (LinearLayout) findViewById(R.id.test);
contentLayout.setDrawingCacheEnabled(true);
contentLayout.measure(
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
contentLayout.layout(0, 0, contentLayout.getMeasuredWidth(),
contentLayout.getMeasuredHeight());
contentLayout.buildDrawingCache();
bitmap= contentLayout.getDrawingCache();
}
解决方案二:
要么getlayoutbitmap有问题,要么你的getview有问题
时间: 2024-10-31 10:21:13