Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9246405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:28:46+00:00 2026-06-18T09:28:46+00:00

I need to make this clickable image similar to an imageMap in HTML. I

  • 0

I need to make this clickable image similar to an imageMap in HTML. I also need to put an icon over the clickable area (in the center, sort of like a map marker), but how do I account for image resizing?

i.e. my image might be 800×600 and the clickable area might be the rectangle covered by 20,20 and 60,40, but these pixels don’t actually refer to the same position in the image anymore when it isn’t displayed on a pixel perfect fashion.

EDIT: my images are taken from sdcard, not from drawable folders

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:28:47+00:00Added an answer on June 18, 2026 at 9:28 am

    This is what i found in this link

    I found myself needing to display an image and have the user tap on
    different parts of the image to navigate and perform actions. After
    sketching out what I needed, it became apparent that what I wanted was
    something like an HTML map tag, but in an Android view. A bit more
    thinking and I decided this would be a useful widget to have
    available.

    The resulting code:

    Supports images as drawable or bitmap in layout Allows for a list of
    area tags in xml Enables use of cut and paste HTML area tags to a
    resource xml (ie, the ability to take an HTML map and image and use
    it with minimal editing) Supports panning if the image is larger than
    the device screen Supports pinch-zoom Supports callbacks when an area
    is tapped. Supports showing annotations as bubble text and provide
    callback if the bubble is tapped The code can be found in GitHub –
    Android Image Map

    Update 2 March 2012: Added an option to always resize the image using
    the original image bits. Certain images, when resized up and down lose
    a lot of their image quality. Always resizing from the original bits
    gives the best possible image, but requires extra memory. The tradeoff
    is now up to you.

    Here are some quick notes about the implementation, I’ll make some
    follow up posts with more details about some of the key areas.

    The ease of associating the map with the img matches the ease of doing
    so in an img tag in HTML. Just supply the name of the map to use in
    the layout:

    <!--?xml version="1.0" encoding="utf-8"?-->
    <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:ctc="http://schemas.android.com/apk/res/com.ctc.android.widget"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
        <com.ctc.android.widget.ImageMap  
            android:id="@+id/map"
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent" 
            android:src="@drawable/usamap"
            ctc:map="usamap"/>
    </LinearLayout>
    

    The area map is specified in your project at res/xml/map.xml One
    difference over HTML maps is that each area must have an id. I went
    back and forth on this requirement, and I may change the code to allow
    for areas without id. The code will use the name attribute if present,
    otherwise it will look for title or alt. The current implementation
    also requires a name for each area, though this could be changed
    easily.

    <!--?xml version="1.0" encoding="utf-8"?-->
    <maps xmlns:android="http://schemas.android.com/apk/res/android">
        <map name="gridmap">
            <area id="@+id/area1001" shape="rect" coords="118,124,219,226" />
            <area id="@+id/area1002" shape="rect" coords="474,374,574,476" />
            <area id="@+id/area1004" shape="rect" coords="710,878,808,980" />
            <area id="@+id/area1005" shape="circle" coords="574,214,74" />
            <area id="@+id/area1006" shape="poly" coords="250,780,250,951,405,951" />
            <area id="@+id/area1007" shape="poly" coords="592,502,592,730,808,730,808,502,709,502,709,603,690,603,690,502" />
        </map>
        <map name="usamap">
            <area id="@+id/area1" shape="poly" coords="230,35,294,38,299,57,299,79,228,79" />
    ...
         </map>
    </maps>
    

    The image itself is placed in res/drawable-nodpi so that the system
    will not attempt to fit the image to the device based on dpi. This way
    we are guaranteed that our area coordinates will map properly to the
    displayed image.

    Here is a sample activity that finds the view in the layout and adds
    an on click handler

    public class ImageMapTestActivity extends Activity {
        ImageMap mImageMap;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            // find the image map in the view
            mImageMap = (ImageMap)findViewById(R.id.map);
    
            // add a click handler to react when areas are tapped
            mImageMap.addOnImageMapClickedHandler(new ImageMap.OnImageMapClickedHandler() {
                @Override
                public void onImageMapClicked(int id) {
                    // when the area is tapped, show the name in a
                    // text bubble
                    mImageMap.showBubble(id);
                }
    
                @Override
                public void onBubbleClicked(int id) {
                    // react to info bubble for area being tapped
                }
            });
        }
    }
    

    Hope this will help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please check this fiddle: http://jsfiddle.net/cZTjd/1/ I need to make the dropdown list fully clickable.
I need to make a table with clickable rows (for this I found some
I need to make this data variable global: $.ajax({ url: get_data.php, cache: false, dataType:
I need to make this function work everywhere, except IE6-7 $(function(){ window.scrollTo(0,300); }) Please
I need to make this design: http://www.stephburningham.com/lmg/ into a joomla template but I've never
I have this code and I need to make this work: if ($handle =
Im working on a polar chart with mschart, and I need to make this
Even .head doesn't work. What changes do I need to make to make this
Not sure exactly what I need to do to make this work, so my
I need to make a query like this: SELECT PNPDeviceID FROM Win32_NetworkAdapter WHERE AdapterTypeId

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.