简体   繁体   English

如何禁用背景屏幕

[英]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. 我有一个LinearLayout A,它是通过setContentView()在onCreate()方法中设置的,但是我在运行时在同一活动中创建了一个PopUp,它也是一个LinearLayout B,PopUp放置在屏幕/活动的底部,我想禁用背景屏幕,以便不进行触摸/点击/单击操作。

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. 这就是我的方法...我建议您将布局的根目录设为RelativeLayout,然后将LinearLayout A放入其中。 Your LinearLayout B should be the full size of your screen and have two views inside it (a top and bottom). LinearLayout B应该是屏幕的完整大小,并且在其中具有两个视图(顶部和底部)。 The bottom view is your PopUp that you are already using. 底视图是您已经在使用的PopUp。 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. 顶部只是基本视图,其背景颜色设置为黑色,上面带有.25(或.1)的alpha,因此几乎可以完全透视。

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). 当您要显示弹出窗口(并禁用与弹出窗口外部控件的交互)时,请将LinearLayout B添加到左上方附加的相对布局中(即B应该完全覆盖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. 用户将能够在底部与您的弹出控件进行交互,并且仍然能够通过布局B的几乎透明的顶部看到LinearLayout A,但是由于它是灰色的,因此用户将知道他们不允许进行交互与它...并且将被阻止与之交互,因为覆盖视图会阻止交互。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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