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.
Related
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!!
I'm using Android Studio to make an app where you can create your own animal, and I want to know how I can layer pictures on clicking a button, if it can be done.
For example, suppose I want to create a teddy bear- I will first click a button to display the bear's plain body, then clicking another button should layer a transparent image of the eyes over the same body (and so on for the nose, mouth, clothes, etc.) I have attached two images as examples of which pictures should appear one over the other when their respective buttons are clicked.
IMAGE 1: This is the body of the bear that will appear when I click the button that says "body"
IMAGE 2: A transparent image of the eyes, dimensions same as the previous image. On clicking the button "eyes" this image should be overlayed onto the previous one
There are many ways of doing it, but I assume you know about OpenGL. That is the standard graphics renderer. With it you can layer as many images as you want.
For instance, you can load the images into the sampler and click-by-click you render the collection of images (given the positioning is taken care of).
I have provided a picture below so you can get a better understanding. Basically I want the user to pick a number from 1-10 which is shown by circles (Only 1 number can be picked at a time). Lets say I pick number 10, as you can see on the picture I want the circle to stroke and change the color when the number is picked (indicating to the user that the number has been chosen). After the number is picked and you press the "blue button", I want to get the value picked to do other calculations.
This is how I want it to be
I feel having a touch based circle is the best way to do it, rather than using a spinner because it take more time. Now the question is how to do this without code duplication or redundancy and how to achieve this in the best way possible. I am thinking I have to create a circle object (Possibly button shaped like circles) 10 times and put text on them, group them in array?..etc or is there a more efficient way to do this.
I'm sure there's better ways to achieve this but I suggest a simple solution as you wanted !!!
Now the question is how to do this without code duplication or redundancy?
You can create a xml file in your drawable folder and put two different oval shapes in that: defaultShape and pickedShape, Use <solid> and <stroke> tags to customize your shapes as you like, and then apply it to your buttons' background.
In order to handle the picking of your button you should implement same onClickListenerfor all 10 buttons, if one of them is picked save it to a temp variable like Button pickedButton, in your listener your check if pickedButton is not null change its background to defaultShape, and assign the new picked one to the pickedButton and then change its background to pickedShape.
Hope you find it helpful.
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
In my android project I have 50 small images that need to be dragged and dropped in three big images.I set that three big images as the background of three different relative layouts.Now I want to restrict the dropped area in all three big images and also want to get the dropped place which will be later used when user came to the same page next time.I dont know how to begin and where to begin?Can anyone help me?I want the dropped place and also restrict the place of dropped....
Thanks!!