• 实现弹出窗口后Activity背景变暗


     1     /**   
     2         * 创建PopupWindow   
     3         */     
     4         protected void initPopuptWindow() {     
     5          WindowManager windowManager = getActivity().getWindowManager();  
     6          Display display =  windowManager.getDefaultDisplay();  
     7          popupWindow = new PopupWindow(popupWindow_view, display.getWidth(),display.getHeight(), true);    
     8           // 设置动画效果     
     9          popupWindow.setAnimationStyle(R.style.Animation_ZoomLight);  
    10           //修改窗口的透明度,从而使Activity背景变暗
    11 WindowManager.LayoutParams params=getActivity().getWindow().getAttributes();
    12 params.alpha=0.7f; 13 getActivity().getWindow().setAttributes(params); 14 //点击其他地方消失 15 popupWindow_view.setOnTouchListener(new OnTouchListener() { 16 @Override 17 public boolean onTouch(View v, MotionEvent event) { 18 // TODO Auto-generated method stub 19 closePopupWindow(); 20 return false; 21 } 22 }); 23 } 24 /*** 25 * 获取PopupWindow实例 26 */ 27 private void getPopupWindow() { 28 29 if (null != popupWindow) { 30 closePopupWindow(); 31 return; 32 } else { 33 initPopuptWindow(); 34 } 35 } 36 /** 37 * 关闭窗口 38 */ 39 private void closePopupWindow() 40 { 41 if (popupWindow != null && popupWindow.isShowing()) { 42 popupWindow.dismiss(); 43 popupWindow = null; 44 WindowManager.LayoutParams params=getActivity().getWindow().getAttributes(); 45 params.alpha=1f; 46 getActivity().getWindow().setAttributes(params); 47 } 48 }
  • 相关阅读:
    mpvue: stylus定义主题色
    mpvue: 单个页面自定义导航栏或隐藏
    mpvue: fsevents is not a constructor
    Nginx:taro h5 Nginx代理配置
    git: 替换remote origin
    taro3.x: h5地图兼容组件封装
    taro3.x: h5地图兼容
    taro3.x: 使用taro-router在H5浏览器返回报错
    taro3.x: tarojs-router
    java线程与线程安全的单例模式
  • 原文地址:https://www.cnblogs.com/jasonxcj/p/4956489.html
Copyright © 2020-2023  润新知