1

In my application, i need to display a map of France, divided into 5 zones. I did it with an image editor : i divided my map into 5 parts and save each part as a png. Each PNG has the same size.

Now, I add 5 ImageView (with the same size) in a RelativeLayout and i obtain this :

France Map 5 Parts

The goal is now to make clickable zones as described on the map. I don't know how to do this (which layout ? how to put them in my layout ?...)

QLag
  • 823
  • 1
  • 13
  • 33
  • I need 5 imageView to change the picture of the zone pressed by the user (the zone will be darker when pressed) – QLag Jan 29 '13 at 21:02

1 Answers1

0

Maybe RelativeLayout? You can place four background images in a regular way (using toLeftOf, toRightOf, below, ...) and one foreground image with alignParentTop and centerHorizontal set to true with proper layout_margins{Top, Left/Right}.

Also remember that android draws xml layouts from top to bottom, so your foreground image should be the last in layout file.

gysyky
  • 460
  • 5
  • 14
  • I thought about that but, no risk that my layouts are at wrong places following size and density of different screens ? (it must work for smartphones and tablets ...) – QLag Jan 29 '13 at 21:25
  • Yes, it is risky. But You can prepare separate margins dimensions for foreground image in density specified folders (values-hdpi, values-mdpi, values-smaill, ...). You can read about it here: http://developer.android.com/guide/practices/screens_support.html You also can read screen dimensions in code, and then programatically set margins based on them. – gysyky Jan 29 '13 at 21:32
  • Okay, i placed 1 vertical LinearLayout containing 2 Horizontal LinearLayouts containig 2 Relative Layout. All the RelativeLayout have a wieght of "1" so as the 2 Horizontal LinearLayout (in the Vert. LinearLayout). I now have 4 regions : [Colored Regions](http://images.meteociel.fr/im/1599/screenshot_dcy8.png). the last problem is to placed the last region "IDF". I think do it programmatically. – QLag Jan 29 '13 at 21:49