80,351
社区成员
发帖
与我相关
我的任务
分享
View view = LayoutInflater.from(context).inflate(R.layout.top_bar_popwin_layout, null);
Dialog dialog = new Dialog(context, R.style.transparentFrameWindowStyle);
dialog.setContentView(view, new RelativeLayout.LayoutParams(context.getWindowManager().getDefaultDisplay()
.getWidth(), RelativeLayout.LayoutParams.WRAP_CONTENT));
Window window = dialog.getWindow();
window.setWindowAnimations(R.style.main_menu_animstyle);
WindowManager.LayoutParams wl = window.getAttributes();
wl.x = 0;
wl.y = window.getWindowManager().getDefaultDisplay().getHeight();
// 设置显示位置
dialog.onWindowAttributesChanged(wl);
// 设置点击外围解散
dialog.setCanceledOnTouchOutside(true);
dialog.show();
// menuDialog.setOnDismissListener(listener);
Display display = context.getWindowManager()
.getDefaultDisplay();
WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
lp.width = (int) (display.getWidth()); // 设置宽度
dialog.getWindow().setAttributes(lp);