AndroidPopWindow设置背景亮度的实例

Android PopWindow 设置背景亮度的实例

为焦作等地区用户提供了全套网页设计制作服务,及焦作网站建设行业解决方案。主营业务为成都做网站、成都网站设计、焦作网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

设置背景 

/** 
* 设置添加屏幕的背景透明度 
* @param bgAlpha 
*/ 
public void backgroundAlpha(float bgAlpha) 
{ 
  WindowManager.LayoutParams lp = getWindow().getAttributes(); 
      lp.alpha = bgAlpha; //0.0-1.0 
    getWindow().setAttributes(lp); 
} 

调用代码

recomPopup = new RecomPopup(mContext); 
      recomPopup.setShowListener(new RecomPopup.ShowListener() { 
        @Override 
        public void show() { 
          backgroundAlpha(0.6f); 
        } 
      }); 
      recomPopup.setDismissListener(new RecomPopup.DismissListener() { 
        @Override 
        public void dismiss() { 
          backgroundAlpha(1f); 
        } 
      }); 
      recomPopup.showAtLocation(include_bottom, Gravity.NO_GRAVITY, 0, DevicesInfoUtils.getScreenHeight(mContext) - recomPopup.getHeight()); 

PopWindow代码

private ShowListener showListener; 
private DismissListener dismissListener; 
 
  @Override 
  public void showAtLocation(View parent, int gravity, int x, int y) { 
    super.showAtLocation(parent, gravity, x, y); 
    if (showListener != null){ 
      showListener.show(); 
    } 
  } 
 
  @Override 
  public void dismiss() { 
    super.dismiss(); 
    if (dismissListener != null){ 
      dismissListener.dismiss(); 
    } 
  } 
 
  public void setShowListener(ShowListener showListener) { 
    this.showListener = showListener; 
  } 
 
  public void setDismissListener(DismissListener dismissListener) { 
    this.dismissListener = dismissListener; 
  } 
 
  public interface ShowListener{ 
    void show(); 
  } 
 
  public interface DismissListener{ 
    void dismiss(); 
  } 

以上就是Android PopWindow 设置背景亮度的实例,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!


网页名称:AndroidPopWindow设置背景亮度的实例
网页地址:http://scyanting.com/article/jehgih.html