另外一种实现给当前界面实现弹窗效果,可不使用dialog和pop window

public void attachView(Activity activity) {

   ((ViewGroup) activity.getWindow().getDecorView()).addView(fullMaskView);

   FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);

   params.gravity = Gravity.BOTTOM;

   ((ViewGroup) activity.getWindow().getDecorView()).addView(contentLayout, params);

}


public void attachToActivity(Activity activity) {

   this.mActivity = activity;

   // .... 省略部分代码

   ViewGroup decor = (ViewGroup)activity.getWindow().getDecorView();

   ViewGroup decorChild = (ViewGroup)decor.getChildAt(0);

   decorChild.setBackgroundResource(background);

   decor.removeView(decorChild);

   this.addView(decorChild);

   this.setContentView(decorChild);

   decor.addView(this);

}

你可能感兴趣的:(另外一种实现给当前界面实现弹窗效果,可不使用dialog和pop window)