How to detects and perform actions on image in Android - android

Please see above image. My requirement is I should able to detect whether on which number I have clicked. This is single image.

use transparent textviews and place them above the numbers and implement their actionlistenerr. But you have to tackle multiple screens resolutions.

Related

Responding to Touch events in different locations in an ImageView android

I need to be able to display different Toast messages to the user based on what object he clicks on inside an image. For example, if we have an image with different types of animals, I need to display the name of the animal based on where the user touches the image.
Would it be possible to add another Views such as ImageButtons on top of the ImageView at specific locations? The problem here is that some images are big enough and should be added to a ScrollView. So would this implementation slow down the app?
So I am asking here exactly at best practices.
Any help is much appreciated!!

Whats the best way to create a view like this in android so that it supports various screen resolutions?

I want to label different images and all the labels must be clickable.Is their a way to add particular hotspots in imageview that respond differently?
Please guide me in right direction.
Just create your own view which draws a bitmap and some lines with texts. if clicked get the position. resolve which text has been clicked.
https://developer.android.com/training/custom-views/index.html

Android varied image position alignment in single layout

I am creating a game with circular buttons. I am thinking about a strategy that allows me to display variety of buttons in variety of positions in the same screen in an efficient way.
Like,
Sample images:
Image 1: 1 button
Image 4: 4 Buttons
The game works on seconds and I want the images to be changing so smoothly and should not take much time for transition. My ideas to implement this are below. Please advise me the best way to achieve this.
Use Grid view and populate items as required.
Use Open GL to display buttons.
Use a fragment and assign layouts as required.
Any other perfect way you suggest.
Note: I don't use strips to animate. All I want to do is just to do some calculation according to which button the player picks to click. And my concerns are,
1. Quick and smooth transition of layouts.
please guide me to pick the right path.
Thanks,
Karthick.

How do I get different click positions in a single ImageView

I am working on an application in which I need to implement Hot Spot kind of thing. Hot Spot is actually an image having different sections in it, when user clicks on different portions of that image it will reflect in different results accordingly, so my problem is that how can I get the click of these different portions which are present in the single Image, also if I get the X-Coordinates and Y-Coordinates of the same Image then how should I maintain it in different screen resolution. I am displaying a demo image with my question
Here its a single image, now I just want to get click of the four section displayed here, for e.g. if I click on section no.4 I can show another image etc.
Please help me to sort this out, any help would be appreciable.
Thank you.
Finally I found a library for this, though it does lot more than what I want to achieve but its good to use this one.
https://github.com/chrisbanes/PhotoView

Image as Background for UI

I am newbi in android world and working on an android app.
I have used many of buttons and image buttons in my app.
Now i want to replace them with an background image. (So i can make nice gui easily)
I know i can use view listener and i can find the clicked x and y coordinate from onclick method.
But I want to how can i find which part of the image was clicked. Because different phones have different resolutions how can i do this efficiently ?
And one more thing, Is it good to handle gui this way ?
Thanks !
You first need to set the initial window width and height before execution of other code and load an image of quality based on the screen size. so for example you can have 3 sets of images of different size. One for 5 inch screens and below. Another for 7 inch tablets. Another for 10 and possibly another super high quality image for anything above. As many devices coming on in the near future are reaching resolutions much higher then previously developed for. Just run code initially that detects the initial window size at hand and load image based on resolution of that device. From their program as you plan to.
Also to jump on answer above. Detect rotation event and adjust image accordingly. and update accordingly. You are adding more programming of course but no reason what you are asking could not be done. Just a few extra events detection and you should be good to go to accomplish exactly what you are looking to do
AFAIK it is not good practice to handle the GUI this way. Mostly because android screen size is not standard and so you can never be sure that it will work perfectly in all the devices. You can ofcourse handle the events using onTouchListener and see which part of image was clicked from the coordinates in the MotionEvent Object. But, I would not recommend doing so.
Creating layouts of different screen sizes and handling the events using Buttons and ImageButtons will be good.
you can use android:background attribute for background images in the layout xml files...
however you also can set the background of UI element programatically

Categories

Resources