简体   繁体   English

活动中的暗淡或模糊背景

[英]Dim or Blur background in activity

In one of my project I used PopupWindow . 在我的一个项目中,我使用了PopupWindow My problem is while viewing popupwindow the design seems to be uncomfortable to work. 我的问题是在查看popupwindow时,设计似乎不舒服。 So I want to dim or blur my activity background. 所以我想调暗或模糊我的活动背景。 I searched a lot, but most of the answers seems only for Dialog not for PopupWindow . 我搜索了很多,但大多数答案似乎只针对Dialog而不是PopupWindow Is it possible in android to dim our activity background while viewing PopupWindaow . 是否可以在Android中查看PopupWindaow暗我们的活动背景。

I solved this problem by setting the background to the layout of the pop-up window with the following. 我通过使用以下内容将背景设置为弹出窗口的布局来解决此问题。

android:background="#80FFFFFF"

Thnaks..And it works as expected. Thnaks ..它按预期工作。

you can simply use this : 你可以简单地使用这个:

ColorDrawable dw = new ColorDrawable(0xb0000000);
dialog.getWindow().setBackgroundDrawable(dw);

There is always a work around. 总有一种解决方法。 Before showing your PopupWindow use another PopupWindow which has nothing but a dark translucent tint. 在显示你的PopupWindow之前,使用另一个只有黑色半透明色调的PopupWindow Also when dismissing dismiss both pop up windows in the reverse sequence. 此外,当解雇时,以相反的顺序关闭两个弹出窗口。

For code see this 对于代码,请看这个

是的,有可能,尝试android:theme="@android:style/Theme.Translucent" ,它会让你的活动透明化。

Try this 尝试这个

 Window window = popUpView.getWindow();
    WindowManager.LayoutParams wlp = window.getAttributes();
    wlp.gravity = Gravity.CENTER_VERTICAL;
    wlp.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    wlp.dimAmount = (float) 1.0;
    window.setAttributes(wlp);

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

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