par*_*thi 2 layout android popupwindow
当我像这样显示弹出窗口时,我希望能够使布局背景模糊或变暗。请问这对我有什么帮助。
这是我的代码:
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);
Run Code Online (Sandbox Code Playgroud)
我的输出显示这个
但我需要这样

像这样在你的布局中声明主要的父级,例如:
RelativeLayout rl = (RelativeLayout)findViewById(R.id.relativeLayout);
然后,当您显示弹出窗口时,还要添加此语句。
rl.setAlpha(0.5F);
这会将布局中的 alpha 设置为 50%。您可以根据需要进行调整。
| 归档时间: |
|
| 查看次数: |
7609 次 |
| 最近记录: |