现在的位置: 首页 > 综合 > 正文

PopupWindow(三)

2013年10月08日 ⁄ 综合 ⁄ 共 510字 ⁄ 字号 评论关闭
                                     // 2、创建界面,显示数据
				View view = View.inflate(context, R.layout.fileinfo, null);
				// 2.1给view添加监听器
				initPopupWindowView(view, position);
				// 3、
				popup = new PopupWindow(view, 400, LayoutParams.WRAP_CONTENT,
						true);
				popup.setBackgroundDrawable(getResources().getDrawable(
						R.drawable.popup_rectangle));
				View decorView = BooksAndTableAvtivity.this.getWindow()
						.getDecorView();
				popup.showAtLocation(decorView, Gravity.CENTER, 0, 0);

这里面需要注意的是:

1、LayoutParams是WindowManager中的内部类,

2、decorView是Activity中Window中的view tree的根节点。

3、效果是PopupWindow弹出的位置在整个Activity的中央位置。

抱歉!评论已关闭.