美文网首页
Dialog加载自定义布局的使用

Dialog加载自定义布局的使用

作者: 阳光下的狐狸 | 来源:发表于2016-12-22 13:51 被阅读0次
private void setDialog() { 
        LayoutInflater inflater = LayoutInflater.from(MainActivity.this);  
        RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.dialog_wuwangluo, null); 
        //新建对话框对象  
        Dialog mDialog= new AlertDialog.Builder(MainActivity.this).create(); 
        mDialog.setCancelable(true);  
        mDialog = mDialog.show();  
        //设置弹出框的宽高  
        mDialog.getWindow().setLayout(400, 300);  
        // 设置弹出框的透明度  
        WindowManager.LayoutParams lp = CartoonDialog.getWindow().getAttributes();  
        mDialog.getWindow().setAttributes(lp);  
        mDialog.getWindow().setContentView(layout);  
    }

相关文章

网友评论

      本文标题:Dialog加载自定义布局的使用

      本文链接:https://www.haomeiwen.com/subject/hlzcvttx.html