【发布时间】:2014-01-10 05:56:00
【问题描述】:
我的 android 应用程序中有超过 8 个活动,所有屏幕都有很多 imageView,它们将用位图图像呈现
当我们打开所有屏幕(活动)时,它会正常工作几次,然后会出现内存不足错误,应用程序崩溃
这是我的代码如何显示图像,请建议如何避免这个/管理这个内存不足问题
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/img_background">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:id="@+id/artifactImage"
android:onClick="displayFullScreenImage"/>
</LinearLayout>
活动:
ImageView artifact_Image = (ImageView) gridView.findViewById(R.id.artifactImage);
artifact_Image.setImageBitmap(artifactImages[position]);
artifact_Image.setDrawingCacheEnabled(false);
【问题讨论】:
标签: android bitmap imageview out-of-memory