views:

45

answers:

1

What I would like to accomplish is to, at runtime, place a button in the middle of the screen, as the very top layer, overlaying anything below it. (It's not big, so it will not completely cover the screen, just whatever happens to be below it.)

I looked at creating a custom dialog, however that blocks all other user input. I want all of the views below this new button to act normally and respond to the user, but I just want to add (and later remove) the button above everything.

Hopefully that makes sense. I'm just wondering what might be the best approach to look into?

Thanks

+2  A: 

Use a FrameLayout, with the button as it's 2nd child. Set it to GONE when you don't want it visible.

Mayra
That worked perfectly. Thanks. Do you know a way to accomplish this without having to change the activities xml layout? All of the activities in my application will need this and it seems inefficient to have to wrap all of the activities' layouts into a framelayout in order to get this popup button to appear over them when needed.
littleFluffyKitty
You could create a subclass of Activity that all of your Activities extend, and have some logic there to programatically insert the particular layout into a FrameLayout.
Mayra