LayoutInflater inflater = LayoutInflater.from(this); 
        // 引入窗口配置文件 
        View view = inflater.inflate(R.layout.statement, null);
        Button btn = (Button) view.findViewById(R.id.btn);
        btn.setOnClickListener(ClickListener);
        // 创建PopupWindow对象  并设置高度和宽度
        pop = new PopupWindow(view, 1000, 700, false);
       
        // 需要设置一下此参数,点击外边可消失 
//        pop.setBackgroundDrawable(new BitmapDrawable()); 
        //设置点击窗口外边窗口消失 
        pop.setOutsideTouchable(true); 
        // 设置此参数获得焦点,否则无法点击 
        pop.setFocusable(true);

 

//位置设置居中

pop.showAtLocation(findViewById(R.id.linear), Gravity.CENTER, 0, 0);

//显示

pop.showAsDropDown(v);

//隐藏

pop.dismiss();