array(2) { ["docs"]=> array(0) { } ["count"]=> int(0) } 111string(0) "" int(1) int(10) int(70) int(8640000) array(2) { ["docs"]=> array(0) { } ["count"]=> int(0) } android开发——自定义弹窗(PopupWindow) - 爱码网

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

相关文章: