【问题标题】:how to set layout background transparent show popup window in android?如何在android中设置布局背景透明显示弹出窗口?
【发布时间】:2014-11-11 05:35:20
【问题描述】:

当我像这样显示弹出窗口时,我希望能够使布局背景模糊或变暗。请帮帮我。

这是我的代码:

LayoutInflater inflater = (LayoutInflater) ResidentActivity.this
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    View layout = inflater.inflate(
                            R.layout.activity_appselection,
                            (ViewGroup) findViewById(R.id.popuplayoutelement));
                    pwindo = new PopupWindow(layout, 470, 540, true);
                    pwindo.showAtLocation(layout, Gravity.CENTER, 0, 45);

我的输出显示这个

但我需要这样

【问题讨论】:

标签: android layout popupwindow


【解决方案1】:

在你的布局中声明主父级,例如:

RelativeLayout rl = (RelativeLayout)findViewById(R.id.relativeLayout);

然后,当您显示弹出窗口时,还要添加此语句。

rl.setAlpha(0.5F);

这会将布局中的 alpha 设置为 50%。您可以根据需要进行调整。

【讨论】:

  • 哦,是的 - 我的平板电脑现在可以更好地利用它的区域了!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-19
  • 2017-04-04
  • 1970-01-01
  • 2018-04-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多