I would like to know how Android manages memory when loading views into a layout and when they are shown and then not shown on the screen.
Basically I'm making an app that requires a very very long page filled with bitmaps and text - similar to a webpage. I know I should use standard views such as GridView and ListView to handle lots of views and images but this is a niche application. (Design is set in stone)
Say I have this layout
<ScrollView>
<LinearLayout>
1000 ImageViews vertically stacked inside here.
</LinearLayout>
</ScrollView>
When the ScrollView is loaded not all the ImageViews will fit on the screen - are the ImageView bitmaps that are not on the screen still loaded into memory? If not, when they are scrolled into view then scrolled out of view with they be removed from memory?
NB: I know that GridViews / ListViews are designed for this purpose but my app has a special design that can't accommodate these views.
Potential Solution: extend the gridview so that it has a fixed height and does not scroll until the ScrollView
it is contained in has reached the bottom. Ie:
<ScrollView>
<LinearLayout>
Lots of text and a few images.
<GridView> <-- attach listener so that touch events are
ignored until at bottom of scroll view -->
1000s of ImageViews
</GridView>
</LinearLayout>
</ScrollView>