@Override
  protected void initUI() {
    super.initUI();
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.WRAP_CONTENT;
    params.height = LayoutParams.WRAP_CONTENT;
    params.dimAmount = 0.5f;

    CloudGlobalDialogPage page =
        (CloudGlobalDialogPage)
            ProxyFactory.getFactory(ProxyFactory.TYPE_CLOUD_GLOBAL)
                .createDetailPage(this, CloudGlobalDialogFactory.NORMAL_GLOBAL_TYPE);

    CloudGlobalDialogPage.Builder builder = new Builder(page);

    if (!TextUtils.isEmpty(title)) builder.setTitle(title);
    if (!TextUtils.isEmpty(content)) builder.setContent(content);
    builder.setOnPositiveButton(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (mOnGlobalClickListener != null) {
              mOnGlobalClickListener.onClick();
            }
            finish();
          }
        });
    setContentView(page.getView());
  }
 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);
  }
示例#5
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);
  }
示例#6
0
  @Override
  protected void displayAD() {
    if (null == mWindowManager) {
      mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    }
    LayoutParams lpWindow = new LayoutParams();
    lpWindow.type = LayoutParams.TYPE_SYSTEM_ALERT;
    lpWindow.flags = LayoutParams.FLAG_DIM_BEHIND;
    lpWindow.dimAmount = 0.8f;
    lpWindow.gravity = Gravity.CENTER;
    Point point = new Point();
    mWindowManager.getDefaultDisplay().getRealSize(point);
    lpWindow.x = 0;
    lpWindow.y = 0;

    lpWindow.width =
        CommonUtils.dip2px(
            mContext, mContext.getResources().getDimension(R.dimen.simple_window_width));
    lpWindow.height =
        CommonUtils.dip2px(
            mContext, mContext.getResources().getDimension(R.dimen.simple_window_height));
    lpWindow.format = PixelFormat.RGBA_8888;

    if (null == mRootView) {
      if (null == mInflater) {
        mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      }
      mRootView = mInflater.inflate(R.layout.simple_window, null);
    }
    mWindowManager.addView(mRootView, lpWindow);
    initViews();
    initDatas();
    super.displayAD();

    SharedPreferences sp = mContext.getSharedPreferences(AMConstants.SP_NAME, Context.MODE_PRIVATE);
    sp.edit().putLong(AMConstants.SP_LAST_AD_STAMP, System.currentTimeMillis()).commit();

    AdDisplayUploadRequest request = new AdDisplayUploadRequest(null);
    request.start(mAD.getDisplayPager());
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.setContentView(R.layout.q3_me_lax);

    final ImageView iv = (ImageView) findViewById(R.id.q3_me_lax_iv);
    final View view1 = getLayoutInflater().inflate(R.layout.q2_pw_me_fc_la, null);
    final View view2 = getLayoutInflater().inflate(R.layout.q2_pw_me_lax_av, null);
    final View view3 = getLayoutInflater().inflate(R.layout.q2_pw_me_lax_lvot, null);
    final View view4 = getLayoutInflater().inflate(R.layout.q2_pw_me_fc_rv, null);
    final View view5 = getLayoutInflater().inflate(R.layout.q2_pw_me_fc_lv, null);

    pw1 = new PopupWindow(view1);
    pw1.setBackgroundDrawable(
        getResources().getDrawable(android.R.drawable.screen_background_dark_transparent));
    pw2 = new PopupWindow(view2);
    pw2.setBackgroundDrawable(
        getResources().getDrawable(android.R.drawable.screen_background_dark_transparent));
    pw3 = new PopupWindow(view3);
    pw3.setBackgroundDrawable(
        getResources().getDrawable(android.R.drawable.screen_background_dark_transparent));
    pw4 = new PopupWindow(view4);
    pw4.setBackgroundDrawable(
        getResources().getDrawable(android.R.drawable.screen_background_dark_transparent));
    pw5 = new PopupWindow(view5);
    pw5.setBackgroundDrawable(
        getResources().getDrawable(android.R.drawable.screen_background_dark_transparent));

    // 设置activity窗口属性
    LayoutParams p = getWindow().getAttributes();
    p.height = (int) (getWindowManager().getDefaultDisplay().getHeight() * 1.0);
    p.width = (int) (getWindowManager().getDefaultDisplay().getWidth() * 0.75);
    p.dimAmount = 0f;
    getWindow().setAttributes(p);
    getWindow().setGravity(Gravity.LEFT);

    /* ib1.setLeft(50);
    ib1.setTop(200);*/
    iv.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View view) {
            if (pwIsShowing()) {
              for (PopupWindow pw : pwList) {
                pw.dismiss();
              }
              pwList.clear();
            } else {
              pw1.showAtLocation(iv, Gravity.CENTER, -100, -150);
              pw1.update(160, 60);
              pw2.showAtLocation(iv, Gravity.CENTER, 10, -10);
              pw2.update(190, 60);
              pw3.showAtLocation(iv, Gravity.CENTER, -100, 80);
              pw3.update(220, 60);
              pw4.showAtLocation(iv, Gravity.CENTER, 100, 120);
              pw4.update(160, 60);
              pw5.showAtLocation(iv, Gravity.CENTER, -100, 180);
              pw5.update(160, 60);
              pwList.clear();
            }
          }
        });
  }