Setting points to click on my Map ImageView - android

I have a blueprint image in my app. The user will be able to click on some pre-established points and after they click on this point, a dialog will show some information.
My question is how I add the specific points in my ImageView Blueprint and the click function on these points?
EDIT 08/08/2014
My ImageView now has pinch zoom and the app will have more than 1 blueprint.
Thanks and regards!

You could go about this multiple ways. If your blueprint is full screen on the users device then you could create your own custom layout to encapsulate the imageview and override the ViewGroup's onDraw an onTouch methods to add your points. Then you could have a method like
public void addPoints(float[] points) { // do something here }
Another option is to extend the ImageView itself and make your own custom imageview and then again override onDraw and overlay the points ontop of the image. YOu can set the bitmap (your blueprint) as the background and then drop ontop of that. You would have to figure out where the specific points are though depending on the size of your image and the device, unless you set the size to be pixel density independent.

The first thing that comes to mind is you could use RelativeLayout in the XML file. This allows you to layer elements on top of one another if you so choose. You could use this to position invisible buttons above the image.
With RelativeLayout, each button could be positioned using its margin attributes, and it should be fairly simple to make the button invisible by assigning the transparent color for its background and providing no text.

Related

Touch bounds for custom buttons in a circle menu

I'll need to implement a UI that reflects the layout of a real object. Below is the layout that the client wants. Each black block is a button, so it need a custom drawable, listeners, states, etc.
I'd like to use a custom implementation of the Button widget, but as far as I know they only accept rectangular touch targets and laying them out could be tricky.
What would you use to achieve this layout?
Please note: the 2 central button should be a semicircle cutted in half (with some padding between the 2), not this strange shieldy shape, I'm just not that good with Photoshop.
EDIT: As suggested in this question I could use a TouchListener on the layout and fake a click on the right button. The main problem with this solution is that I'll need to know the bounds of the drawable, not the rectangular ones of the button's bounding box (that is always rectangular). How could I do that?

how to make large image clickable on different different image part

I want to implement a application in this application multiple click event like periodic table i want to use large image for this and make image clickable from its different different part called element in this implementation zoom and scroll feature are also include
Try this:
Define a Rect for the spot/area that you would like to make clickable. Also remember to redifine it based on screen layout size and resolution.
Now onTouch event get the x and y position and calculate whether it lies within the defined Rect and act accordingly. The Rects will act as virtual image maps.
I think you have to divide your large image into sub images and add these sub images to every image view. You have to create a layout such that all these image views must show the original large image without any disturbance at corners, then only you can get separate click events for each sub image.
I think that this is a good idea.
Use a "layer" with different alpha level areas. Each area with a specific alpha level is a specific action-click.
https://groups.google.com/d/msg/android-developers/_6u3Iu-sYrI/DA0KCo8pTksJ

how to design this UI in android app

i am trying to create the following UI in android app
In the above image all the five are to be image buttons. How to design this UI as like in the screen shot please help me friends....
Inside LinearLayout take RelativeLayout and make it centrally aligned.Then
Take first image Near me and set it's property.
Now take the second image Explore and set it to right of first image.
Place third image My network and place it below first image.
Fourth image Live set this to right of third image and and below second image.
Now center aligned your center image.
You will need to create 5 images, each of which has transparent areas. This layout type lets you position elements relative to the layout group itself, as well as to items within the group.
I'm not very familiar with Android advanced layout design, but the common layout objects give an idea:
There is a SurfaceView which gives you the ability to manipulate z-coördinates. In the SurfaceView you can then place a Grid/Relative/TableLayout for the 4 buttons (which you pre-render as rectangular images with transparency) and a simple Layout which centers and only contains the middle button.
If you then set the Z value of the first layout to less than that of the second you will get the view you want.

Specific Parts of ImageView clickable

What are some ideas about having an ImageView that takes up the whole screen and making only parts of it clickable? I was thinking that I could extend the ImageView class and override its ontouch method which would allow me to detect touches based on an x and y. The only problem I can see with this is on different resolutions the touches might not map to the correct areas. I suppose I could then detect the resolution and figure out some way to map the x and y to the correct areas. I feel like there must be an easier way though. Does anyone have any other ideas?
How about creating transparent views with your desired click listeners on top of the ImageView using a RelativeLayout. You can use the xml to place those "hotspots" where you would like them relative to your image and define the layout so the "hotspot" view scale properly along with the image when displayed on different resolutions.
If the 'hotspot' shapes are not too complex, you could dynamically split the image, setup individual clicklisteners and re-merge the drawables in a way for them to appear contiguous. I do like Gregg's method more though.

Android. Draw bitmap between two layouts

I want to make application which will have background and some picture with alpha channel in front. Between them i want to draw bitmap/animation.
How can i do it ?
That is easy. You can use FrameLayout as the root layout and set a background to it. Then add two more LinearLayouts which fill the screen. In the first you may add your animated views like ImageView, while in the second you can insert an ImageView or ImageButton with a transparent image in it.
There are many other ways to do this like using a custom view for your animated layer etc. Check my example here: How can I use the animation framework inside the canvas?

Categories

Resources