Is there a way for user interface elements to overlap slightly (one on top of the other) without using absolute layouts?

Say I have a list on the screen that I always want to use. I also want the small image or text image to slightly overlap the list. Is this possible without using absolute layout options?

I have never seen it in any Android app or tutorial, but many iPhone apps have such things. This adds a pleasant touch.

(Also, I don't have code to show because I'm not sure where to start)

+4
source share
3 answers

Relative layouts also allow you to overlap things. Views declared later in xml will be on top. I believe that aligning the edges of the view and using fields should allow you to achieve this effect without too much difficulty.

+4
source

You can use RelativeLayout and set, for example, android:layout_marginTop="-50dip" android:layout_below="@id/my_list" .

+2
source

Besides RelativeLayouts, you can also use FrameLayouts to stack objects. Besides the z-order (last declared object = highest z-order), child objects are independent of the location of other objects in the group, so you can simply set the fields or gravity to place them.

So, in your instance, just declare a TextView after the ListView and place it where you want. It will not interfere with the positioning of the ListView, and it will sit on top.

+2
source

All Articles