private void showAsPopup(Activity activity) {
   activity.requestWindowFeature(Window.FEATURE_ACTION_BAR);
   activity
       .getWindow()
       .setFlags(
           WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND);
   LayoutParams params = activity.getWindow().getAttributes();
   params.height = LayoutParams.MATCH_PARENT;
   params.width = 850; // fixed width
   params.alpha = 1.0f;
   params.dimAmount = 0.5f;
   activity.getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
 }
  private void setWindow() {
    WindowManager m = getWindowManager();
    Display d = m.getDefaultDisplay(); // Ϊ��ȡ��Ļ�?��
    Point outsize = new Point();
    LayoutParams p = getWindow().getAttributes(); // ��ȡ�Ի���ǰ�IJ���ֵ
    d.getSize(outsize);
    p.height = (int) (outsize.y * 0.8); // �߶�����Ϊ��Ļ��0.8
    p.width = (int) (outsize.x * 0.8); // �������Ϊ��Ļ��0.8
    p.alpha = 1.0f; // ���ñ���͸����
    p.dimAmount = 0.0f; // ���úڰ���

    getWindow().setAttributes(p); // ������Ч
    getWindow().setGravity(Gravity.CENTER); // ���ÿ��Ҷ���
  }
  public UserInfoDialog(Context context) {
    super(context, R.style.Dialog);
    setContentView(R.layout.user_center_content);

    // 设置点击对话框之外能消失
    setCanceledOnTouchOutside(true);
    // 设置window属性
    lp = getWindow().getAttributes();
    lp.gravity = Gravity.TOP;
    lp.dimAmount = 0; // 去背景遮盖
    lp.alpha = 1.0f;
    lp.y = 55;
    getWindow().setAttributes(lp);
  }
Exemple #4
0
  public LoadingDialog(Context context) {
    super(context, R.style.Dialog);

    this.mContext = context;

    inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.loadingdialog, null);
    setContentView(layout);

    // 璁剧疆window灞炴�
    lp = getWindow().getAttributes();
    lp.gravity = Gravity.CENTER;
    lp.dimAmount = 0; // 鍘昏儗鏅伄鐩�
    lp.alpha = 1.0f;
    getWindow().setAttributes(lp);
  }