Identify portions of image which is to be shown in ImageView - android

I have got an image with different arbitrary shaped portions in it.
Now I want to show some data when clicked in the particular portion of the Image. e.g. When I click in the portion A, I want to show a notification with name of the portion.
I don't have idea on how to achieve this task. Please guide me on this.

Try to add an OnTouchListener to get the coordinate where your image gets touched. With these coordinates you could match the shape what is clicked.

Related

Android - How can i split image to specific shapes(not rectangle or square)

I want create images for each state.. (texas,montana,california.....)
Example image USA map :
I tried put images over and over for each states like below (50 states, 50 images)..
For example Texas image :
It was bad way.. Can i achieve this another way? or different opinion?
Use free crop in PicsArt. Go to edit and select the picture. Select tools and then free crop. Colour in the bit you want to keep and save it. I hope this helps!
I'd suggest you using 2 ImageViews - one on the top of another. On the bottom ImageView you can draw image of whole map without the State names.
On the top ImageView you can draw the names only.
Then you set onTouchListener to the ImageView, and on touch you just get the color of touched pixel. After that you match touched color with the state colors, and this way you know, which state was clicked.
For this every state has to have it's own color.

detect which part of image is clicked

I want to make an app in which I ll show a human body. when we click on any body part the organ name should be displayed with a toast. How will I detect which body part is selected. According to me i ll make small images for every organ. and place those images behind the main image. Is it the right way? How will I draw organs(Bitmaps or png images?).
I think an easier way to do it is to draw shapes or even buttons over your image, and define them as transparent so you don't see them. Then, using onClickListener you can capture what button is clicked and do whatever you want.
Check this for an example

Set buttons on image in specific locations

I'm trying to crate custom map in my application, the needed map is not Google map, its consists of image and small pins images, in other word its image view,,, i need to set buttons on this image in specific locations, and wen these buttons clicked , i need to perform some action, the problem is i didn't found a way makes me able to set buttons on this image at run time, the image and the buttons locations will be received from the server side, so i need to create this custom map at run time. maybe i need to set the buttons on specific pixels, but i don't know how i can reach specific pixels in the image, i appreciate any help in this. thank you all.

set up different clickable part image android

Im working with android about image and onclick listener. The purpose of my app is to monitor the area that user clicks on the screen. For example, I have a picture containing a rectangular and a circle. Assume that the color of the whole picture is brown(wood). So when I click on the rectangular, the color of rectangle will change to yellow. When I click on the one part of the picture, the color of that part will change its color, but other parts do not change. So, Im thinking about the solution for this app. Do I have to cut this picture separately and put them into the screen by using relative review? Or is there any other way to do this(Set up a coordination system)?
Yes you have to cut this picture separately and put them into the screen by using relative review. For example two ImageView with your backgound.
You can slse the image as recommeded by the other post, or overlay the image with a RelitiveLayout with specific sized buttons (background = #android/color/transparent)

How to implement multi-images on screen, each can be selected, moved, rotated, zoomed and bordered?

User can select some images to the screen, and be able to select/drag/move/zoom/rotate each image. When an image is selected, it will have a blue border. And user can also bring an image to the front or background.
Here is sample picture in the following: there are two images(girls) on a star-background. The top one has been selected(it has a blue border).
I don't know have to implement it. For several days of learning, I can now drag/move/zoom/rotate a single image(inside an imageview, and scaled by matrix). But I don't know how to handle multi-images.
I want to know:
Is it still a good idea to use ImageView(for each image), or what classes should I use?
How to implement the orders? (so I can bring them to front or background)
How to determine which image has been selected
How to find and draw the border of selected image?
For now, I just know how to use ImageView, but I'm not sure if I can use it to implement this task. Please give me some advices, thanks !
Drawing everything directly onto a Canvas is one way of doing it. There is an article that covers the basics of using a Canvas. You can read it HERE
There is one major downside in doing this - you have to handle all the input events by yourself. The API won't tell you which image has been clicked, or dragged. You'll have to implement that by yourself.

Categories

Resources