wonglik
wonglik

Reputation: 1069

How to make object overlay another object in Android layout?

What I am trying to do is to have a menu appear over listView. Just like in okCupid app :

when you click menu below the picture : https://ssl.gstatic.com/android/market/com.okcupid.okcupid/ss-480-3-11

it extends itself over the background view : https://g1.gstatic.com/android/market/com.okcupid.okcupid/ss-480-4-11

I have a feeling that this particular app is done in Sencha or JQuery mobile or similar technology but is it possible to get same effect in native app?

thanks

Upvotes: 2

Views: 2769

Answers (3)

caguilar187
caguilar187

Reputation: 763

I can look around for some example code later but the basic idea would be to have a MenuView class that draws your menu and animates in and out by setting the content of the menu visible or not.

Then just have all your content be on top of that MenuView by using the relativelayout align_parentBottom and set the content to above the menuview.

Upvotes: 1

Kiran Babu
Kiran Babu

Reputation: 1893

Try using FrameLayout and add appropriate transperency for the view

Upvotes: 1

Kris Van Bael
Kris Van Bael

Reputation: 2862

Most layout classes 'help you' by avoiding widgets to overlaps, but with the RelativeLayout you have more flexibility to create overlapping views.

To be sure the overlay view is on top, you can call ViewGroup.bringChildViewToFront() on the relative layout.

In your example the top view also has a partially transparent background.

Upvotes: 2

Related Questions