纯属网上找的资料
1 xml 中背景图片和ImageView释放------尤其注意图片资源
- 先获取图片控件:
- public ImageView imageView;
- public LinearLayout linearLayout;
- imageView=(ImageView)findViewById(R.id.main_cion);
- linearLayout=(LinearLayout)findViewById(R.id.mian_bg);
- 应在次Activity销毁时释放
- protected void onDestroy() {
- super.onDestroy();
- imageView.setImageBitmap(null);//释放
- linearLayout.setBackground(null);
- System.gc();//通知进行回收
- }
-
使用Bitmap记得不用时调用回收
- bitmap.recycle();
总结:
无论你是在xml中布局使用了:
android:background ,
还是在java代码中调用了:
setBackground( background );-------API16+
setBackgroundDrawable( background)--------API16-
setBackgroundResource( resid)
的方式去设置了背景图片.
使用的时候,请调用一下对应的方法:
setBackgroundResource和 android:background → setBackgroundResource(0);
setBackgroundDrawable( background) → setBackgroundDrawable (null)
setBackground ( background ) → setBackground ( null )
然后再onDestory中调用System.gc();
浙公网安备 33010602011771号