Tag Archives: images

Three Variations for Image Square Grids in Android

In a new Android app I am working on, I have a need to display a a square grid of images. I have tried several variations of doing this using a GridView. Each of the solutions involves using aViewTreeObserver, which is something I would not have thought of on my own. Fortunately, I found several notes on StackOverflow that pointed me in the right direction.

I’ll describe three of the variations in this blog post. The end result for each variation is good: square images on a grid. My favorite variation is the one in which the sizes of the images are determined dynamically, based on the size of the screen. It requires the least amount of work and delivers good results.

Complete source code is provided for all three variations.
Continue reading

Posted in Android | Tagged , , , , , , | 4 Comments

Android Images With Clickable Areas – Part 1

I want to display images in Android and have different clickable regions within the image. I have read about two different ways of doing this. The first is a bit like image maps in HTML. You define areas on the screen, using a list of coordinates, and connect the areas to actions. The second method involves overlaying a hotspot image on top of the real image being displayed. The overlay image has exactly the same size as the first image. It uses different colored regions to indicate the hotspots. When the user clicks on the primary image, code runs to check the pixel at the corresponding point in the hotspot image. In this, the first of two articles about image maps in Android, I will explain what I learned for the second technique. Full source code is provided for this sample app.
Continue reading

Posted in Android | Tagged , , , , | 91 Comments