How to make a part of jpg clickable in android -
as in example image. want use image background , want portion of image building , towers clickable open new activity in app.
you can achieve mapping image , comparing click rect areas mapped image.
after mapped (probably directly on code) have onclicklistener this:
public void onclick(motionevent v){ for(pair<rect,actionlistener> areas : mappedareas) if(areas.first.contains(v)) areas.second.onclick(v); }
ps: have problems absolute values on different screen sizes (if component allows fit_screen) should map relative coordinates (percentage) , convert absolute values before comparing.
Comments
Post a Comment