final AlertDialog dialog = new AlertDialog.Builder(context).create();        dialog.show();        Window window = dialog.getWindow();        window.setWindowAnimations(R.style.dialogWindowAnim);//设置对话框显示和消失动画        window.setLayout((int) context.getResources().getDimension(100dp,100dp));//设置对话框的大小        window.setBackgroundDrawableResource(R.drawable.tanchuangbeijing);//设置对话框的背景        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);        View view = inflater.inflate(R.layout.dialog_prompt, null);        TextView tvDesc = (TextView) view.findViewById(R.id.tv_desc);        if (!TextUtils.isEmpty(text)) {            tvDesc.setText(text);        }        Button btnPositive = (Button) view.findViewById(R.id.btn_positive);        Button btnNegative = (Button) view.findViewById(R.id.btn_negative);        btnPositive.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                if (positiveListener != null) {                    positiveListener.onClick(v);                    dialog.dismiss();                }            }        });        btnNegative.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                dialog.dismiss();            }        });

              //默认显示在窗口的正中间,但是可以通过x改变水平位置,y改变垂直位置,x为正向右偏移,反之向左偏移,y为正向下偏移,反之向上;

        WindowManager.LayoutParams attributes = window.getAttributes();
        attributes.x = x;        attributes.y = y;        window.setAttributes(attributes);        window.setContentView(view);

更多相关文章

  1. android 自定义用相机拍照后的照片存储位置
  2. Android之百度地图开发,包含定位,覆盖物,经纬度位置转换,长按设置中
  3. android 获取手机位置信息
  4. [置顶] Android 实现对话框圆角功能
  5. Android,对话框定时自动关闭的实现
  6. 修改AVD存放位置
  7. 在任意位置获取应用程序Context

随机推荐

  1. 更改时间、时区
  2. 两集合比较判断
  3. 自动化运维Ansible
  4. Jenkins入门(一)
  5. Jenkins入门(二)
  6. ELK入门
  7. JavaScript:鼠标事件,动态创建导航下拉列
  8. jq:初学 与 getter/setter方法
  9. 换肤案例以及选项卡
  10. 新网站快速排名大量收录方法教程