欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Android PopWindow 设置背景亮度的实例

程序员文章站 2023-12-10 16:24:34
android popwindow 设置背景亮度的实例 设置背景  /** * 设置添加屏幕的背景透明度 * @param bgalph...

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 设置背景亮度的实例,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!