4

I have a clickable imagemap to indicate positions on a body. On clicking an area, an additional image will be shown indicating that area was clicked. I have that working, but the additional image does not align correctly with my map. To see the problem I modified my view to show all images at once, in stead of only when clicked at.

<!--?xml version="1.0" encoding="utf-8"?-->
<RelativeLayout     
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:ctc="http://schemas.android.com/apk/res/com.example.sbar"
 android:id="@+id/my_frame"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent" >

 <com.example.sbar.ImageMap
    android:id="@+id/map"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:src="@drawable/sbar"
    ctc:map="sbar"/>

<ImageView
    android:id="@+id/l1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignBaseline="@id/map"
    android:src="@drawable/l1"
    android:visibility="visible" />

<ImageView
    android:id="@+id/r1" 
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"
    android:src="@drawable/r1"
    android:visibility="visible" />
</RelativeLayout>

the result is like this:

enter image description here

Tasos
  • 5,321
  • 1
  • 15
  • 26
wim
  • 53
  • 5
  • maybe you should try the flood fill algorithm rather than superimposing images -- http://stackoverflow.com/questions/8801047/how-to-fill-color-in-image-in-particular-area - – Tasos Jan 03 '16 at 14:12
  • 1
    Thank you. I rather keep the images tough, as I need them as part of a html email and I need to remember which area was selected. I planned to do the following on clicking on an area: name = mImageMap.getName(id); if (name.equals("L1")){ l1.setVisibility(View.VISIBLE); } – wim Jan 03 '16 at 15:10
  • 1
    I got it working now, Needed to replace android:src="@drawable/l1" by android:background="@drawable/l1" ! The images align now perfectly. – wim Jan 03 '16 at 15:55

0 Answers0