Android ImageView ontouch - android

I want to implement body part selection in android. My requirement is, when I tap on specific part the image app should be able to identify the body part and color of the selected part should change.Attached a sample image for reference.
Any idea or suggestion at the earliest would be very much appreciated.

In your input, set x,y position each part of body.
Then you can calculate nearst part of touch x,y with simple code.
Or more complex, you can set rect.
In visual part, you can add another imageview overlay original image.
If your image is separated, you can use
imageView.setColorFilter()

Related

Add OverlayView on ImageView in Android at particular X-Y Co-ordinate

I have back side TouchImageview, which having zoom in/out functionality, I am setting up bitmap on ImageView, the size of Bitmap is w-h (2100 x 2900), I have particular X-Y co-ordinate, now I want to add Overlay view at same co-ordinate as per imageview's X-Y co-ordinate, the background imageview should be touchable.
Can you please let me know solution for the same.
Thank you.
I'm an iOS developer, but can be answer to your question, as I'm sure that these things are also possible in Android ! ;)
You can follow these steps:
Don’t make any change in your current flow.
Add overlay view the way you want.
Take screenshot of the back image view which are showing location, may be of particular size (or the exact size of circle on overlay).
Show that captured screenshot (image) at circle view position (you can have an another image view for that).
Zoom that image view (From Step.4)
You are done!
Goodluck.

Positioning an image on top of an image with specific coordinates in Android

End Goal: Getting a speedometer style needle to move around a dial according to test results.
Current Issue: At the moment I have placed the needle on top of the speed dial as a sperate image using FrameLayout. I have been scouring the web for a way to position the needle with coordinates so I can have it exactly where I want it on the dial. I would post an image but I'm new to the forum and I'm not allowed!
So in short can I position an image over another image with exact coordinates (allowing for rotation etc)? Am I going the right way about solving my problem?
There is the AbsoluteLayout, which lets you use absolute positions, but it is not recommended that you use it.
Instead, you should create your own extension of a View, that draws your dial and needle. For more info on this, look at Maurycy's comment, which recommends this part of the manual.
Calculate measurements and rotate image of indicator accordingly.

Is it possible to get the points of bitmap as path?

suppose my bitmap is like
This image is actually in square transparent. I want to get the only viewable points as array so I can bound it and handle touch event on canvas. Right now it is square so when I touch at the corner of the image it still detect touch event on image. i don't want to do like this. Only if user clicked on viewable part then only action would be taken otherwise not.
For temporary I have used radius of image from center point it works fine but accurate, also if this image triangle part length is long then if it remain in square format user fill/get event on image outside.
I have used canvas to draw bitmap. Is there any other way or easy way to do this thing and handle event.
I have seen many games in that they used like custom shapes and touch event fire only on display part of object, how could i achieve this things.
Take a look at coordinates:
Android Canvas Coordinate System
and
http://code.google.com/p/apps-for-android/source/browse/trunk/SpriteMethodTest/src/com/android/spritemethodtest/CanvasSprite.java?r=150
Which goes into sprite:
http://p-xr.com/android-tutorial-how-to-paint-animate-loop-and-remove-a-sprite/
This may help too:
http://www.droidnova.com/playing-with-graphics-in-android-part-vi,209.html
Some of that should be helpful.

How to get correct imageview coordinates with moveable image

I would like to be able to view a rather large image (floor plan) that can be fully viewed by moving around the picture. When I click on the image, I would also like to get the coordinates on that image.
I've followed this tutorial 1 which works correctly and so allows me to move around the image. After that I also added some functionality to get the position of where I touch the screen. However, when moving around the image, black borders surround it (see picture below), which causes me to get incorrect coordinates.
So would somebody know how I could a) fix/remove the black borders when moving the image or b) correct the coordinates I receive by e.g. removing the border offset?
1 http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-2-building-the-touch-example/1763
When you move around the image, set the scroll to stop before it reaches the edges of the image. Use this link for further details.
As for your coordinates, check these other 2 links: link1, link2.
Hope these would help you.

How to animate Bitmap on Surface view onDraw()?

I am trying to make a game. I try to use GridView but wonder how can I drag Item onTouchEvent(). I found an example
http://www.droidnova.com/playing-with-graphics-in-android-part-ii,160.html
It is a great example. I cropped my image in 12 small image bitmap. display them on screen randomly on specific position.
By overriding the onTouchEvent() I got my requirement. Now I want to animate my image as the "swap" other image by animating. I have both images X,Y location.
I am wondring if it can by done by some Animation class.So that I should not put effort for doing it manually. I know it is not a hard job. But I Animation class can do it more smoothly.
So I have a ArrayOfImages(Bitmap) and I want to swap 2Images with animation. I am using a thread that update "Canvas" in background. Please help me.
.
I more thing. How can I add Scroll view with surface holder?? Is it possible? Because I think when I try to drag my image , It my not drag and active scrollbar for this response?
Finally I am using a loop for a specific x,y to a specific x,y while updating the canvas. Although this is not a efficient way.

Categories

Resources