简体   繁体   中英

How to disable background screen

I have a LinearLayout A which is set inside onCreate() method by setContentView(), However i am creating a PopUp at runtime in same activity which is also a LinearLayout B, PopUp placed just bottom of the screen/activity, I want to to disable the background screen so that no touch/tap/click work.

How can i do that.

Thanks

This is how I could do it... I would recommend that you make the root of your layout a RelativeLayout, then put your LinearLayout A inside that. Your LinearLayout B should be the full size of your screen and have two views inside it (a top and bottom). The bottom view is your PopUp that you are already using. The top will just be a basic View that has a background color set to black with a .25 (or .1) alpha on it so that it's almost entirely see through.

When you want to display your popup (and disable interaction with the controls outside of the popup), add LinearLayout B to your relative layout attached to the top left (ie B should completely cover A). The user will be able to interact with your popup controls at the bottom and still be able to see LinearLayout A through the mostly transparent top portion of layout B, but since it is slightly grayed out the user will know they aren't allowed to interact with it... and will be prevented from interacting with it because the overlay view will block interaction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM