Draw images on top of each other in android - android

I have some images that I want to put on top of each other on random order.
If it possible using one ImageView or do I need to create multiple image views based on number of images?

You don't completely specify what you want.... if you want the images to be placed in different positions (in the X and Y axis), meaning that while watching the photo on the top you can see part of the other images, then you have to create different ImageViews, or drawing them on a canvas (I think this one is much better).
If the images are just one on top of the other (hiding the one on the bottom), you just have to use one ImageView.

LayerDrawable may fit your requirement, you may refer to this post overlay two images in android to set an imageview

Related

Create a composite of two images in android overlaying a specific section

I have two images I wish to merge together into one, the image that will become the background is configured so that the section I wish to overlay the second image on is coloured.
Is there any way to dynamically generate a composite of two images overlaid over a specific section?
Assuming the images have a least a little bit of alpha, you will have to use the Canvas class to draw the bitmaps. Here's a link to the method documentation.

Android: creating custom 2D avatar

I am creating an app that allows a user to build a custom 2D avatar by specifying things like shoes, socks, skin color, etc...
Currently my solution has been to create a .PNG of each item and then to 'stack' them all on top of each other in a RelativeLayout. So for example, I create an ImageView of two shoes and align the ImageView to the center of the relative layout and the bottom of the Relative Layout. Next I 'stack' the bottom edge of the socks to the top edge of the shoe. And on and on.
This method works, but I feel like I don't have much control over where the parts sit and would much rather be able to calculate the x,y coordinates at run time and place the images that way. For instance, this works well if all of the ImageViews are stacked, but if I need to place one ImageView 10 pixels below the top edge of another ImageView I can't do it (or at least I haven't figured out how yet).
I am looking for a solution that will allow me to control the x,y position of ImageViews and allow ImageView to be offset from each other.
If you'd rather place the images by x,y coordinates, then you should consider using a single view and simply drawing the images on top. See this doc on custom drawing. You'll find drawBitmap and some of its overloads useful.

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

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.

What is the best view for a displaying an images in android?

I'm designing an app that splits an image into a 3 x 3 grid. What is the best way to display this image.
Also, How can I move this piece from one point to another on the view.
Thanks.
Use an ImageView? I don't understand your second question. If you are talking about trying to show the 3x3 grid, use a GridView.
You can mess around with the ScaleType and image matrix to change what part of an image is displayed.

Categories

Resources