My end goal is to create an Activity in Android that displays two or more images in a scrollable vertical list. The problem is I keep trying different Views and I’m not sure what the best choice is for my situation.
The ideal implementation will allow me to do all of the following:
- Display images asynchronously as they are fetched from the server.
- Avoid VM memory issues when I have 10+ images.
- Zoom/pan either all images at once or images in individually
My implementation uses a single bitmap comprised of all the images in a custom SurfaceView but I can already see how it makes #1 and #2 difficult. I only have #3 working.
I’ve also tried using a ListView but I couldn’t successfully implement #3.
I’m relatively new to Android development but the way I see it the custom SurfaceView can give me #3 and a custom ListView can give me #1 and #2. Would creating a ListView comprised of custom SurfaceViews (one per image) be the right approach or am I way off track? Is there a better approach to my situation?
I ended up resolving this by using a ListView comprised of ImageViews. This resolved #1 and #2. Then to deal with pan/zoom I added an onClick listener to the rows of the ListView. This fires an Intent passing the ImageView’s bitmap to a new activity which uses a SurfaceView to render the bitmap where I hanlde zoom/panning for #3.