I'm writing a "very-long-scroll" game. The game's main element is ScrollView, which I filling with "blocks".
One "block" looks like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/sec3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/_40" />
</LinearLayout>
The Image's (.jpg, 720x6000) size is 800-900kb. I'm filling my ScrollView with following code (for one type of images):
View block_3 = inflater.inflate(R.layout.block_3, null);
for (int i = 0; i != Blocks.block_20; i++) { //Filling the LinearLayout in ListView with 20 blocks
LinLayout_in_ScrollView.addView(block_3, layout_params);
}
But my app crashes with OutOfMemory error. I've tried to use the ListView instead of ScrollView, but I failed. I thought about dynamical loading items in ScrollView, but it will be very hard to do. So how I can avoid the OutOfMemoryException?
P.S. Excuse for my English, please.