I am trying to implement this for so many days. I have read every single post here but I cannot get it done. Everything thas was suggested using methods such as getIntrisicHeight() doesn't seem to work as I want on every screen that I try it. So I am thinking o a solution like this: https://stackoverflow.com/a/4942812/1113997. The problem is that I don't understand many points of that answer:
- Can anyone give me an example of the xml file?
- What should I check after the return? I mean I will have something like a map and have several areas colored with different colors (in my invisible image,right?) and then if I press the area with the red colour do something, if the green one do something else. Can anyone complete the answer by giving an example of the code?
- How do I know that the same red I draw my image on paint for example, will be the same that it will be compared?
Code form the link:
private int getColour(int x, int y) {
ImageView img=(ImageView)findViewById(R.id.img2);
img.setDrawingCacheEnabled(true);
Bitmap hotspots=Bitmap.createBitmap(img.getDrawingCache());
img.setDrawingCacheEnabled(false);
return hotspots.getPixel(x, y);
}