Im new to Android and over the past few days I have been over many tutorials, I was wondering if you could help me with some advice.
I want images on top of each (not completely, there may be some overlapping) other with each image to be clickable.
Whats the best way to do this? Have each image in an image view? Can these be positioned on top of each other? And have onclick listeners?
Thanks for your help
Imageviews can be stacked by using the framelayout. The framelayout add each child view on top of each other based on the order of the childs ie the last child will be the top most.
Jep, ImageViews are appropriate. Add them to a RelativeLayout and add a onClickListener and you are done.
Have a close look at RelativeLayout's align* attributes.
HTH.
Related
Hey guys I have 26 buttons nicely arranged in a gridlayout but I am trying to achieve something. I want the buttons to shuffle and place themselves randomly in cell positions in the grid layout on a button click. AND none of them should be placed above another. Please can this be achieved? All suggestions are welcome. Thanks in advance.
GridLayout child positioning is solemnly bound to child index.
Which means to achieve random positioning all you need is randomly change child positions by using [ViewGroup.addView(View, int)](http://developer.android.com/reference/android/view/ViewGroup.html#addView(android.view.View, int)) and View.removeViewAt(int)
As for not placing above each other, the grid layout child distribution takes care of all this.
I finally did it. I just had to create a Random variable, remove each view and place them at a new random index
OK first I'm not actually moving buttons I'm moving imageviews that have an onclick listener. What I want to do is drag multiple imageviews around inside a layout. I was going to use a FrameLayout but it seems that wont work for multiple items.
Can anyone tell me which layout is suitable for this?
thanks in advance
Linearlayout with a vertical orientation should do it for you..use margain_direction for fine tuning it further
Maybe a GridLayout would suit your needs? You can have one or multiple child views in each grid cell.
In my android app I am not able to move vertically when I put a map inside a Scrollview and if I am using other layouts then the items at the bottom are not visible.I had seen all the solutions provided before my question but couldn't found any appropriate solution..Thanks in advance if anybody could be able provide me solution who to do it ?
Scroll view by default only scrolls vertically. Have a look at this answer, it might solve your problem.
I have one absolute layout which contains many ImageViews. I have implemented Drog and Drop functions for all imageview. Now what happen when suppose i drag one imageview over another imageview then first view goes back side because it have been added first compaire to another one . I need that moving view always visible on top.
So can i solve this problem ?
Thanks in advance.
Probably the easiest way to avoid this is to call .bringToFront() on your ImageView when you begin your dragging code.
http://developer.android.com/reference/android/view/View.html#bringToFront%28%29
How can I have two images stay on top of each other.
In other words, the position of image 1 is exactly the same as the position of the second image; one image is covering the other completely?
Use a FrameLayout and then put your two ImageViews inside it. Children of a FrameLayout stack on top of each vertically.
I think RelativeLayout is what you are looking for.
You should take a look at FrameLayout. Adroid have an example of using FrameLayout. Read up on this good example, and you'll have a better idea of how to tackle your problem.