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();

相关文章:

  • 2021-08-18
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-02-07
  • 2022-12-23
猜你喜欢
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-19
  • 2021-04-28
相关资源
相似解决方案