• popupWindow弹出来后,背景变暗,半透明


     1 /**
     2      * 点击评分,如果评分后,显示的弹出框
     3      */
     4     private void showMakeGradeMarkedWindow() {
     5         View view = LayoutInflater.from(DetailActivity.this).inflate(
     6                 R.layout.grade_screen_marked, null);
     7         final PopupWindow mPopupWindow = new PopupWindow(view, 469, 280);
     8         mPopupWindow.setFocusable(true);
     9         ColorDrawable dw = new ColorDrawable(0xb0000000);
    10         mPopupWindow.setBackgroundDrawable(dw);
    11         mPopupWindow.showAtLocation(install, Gravity.CENTER, 0, 0);
    12  
    13         final RatingBar mraRatingBar = (RatingBar) view
    14                 .findViewById(R.id.grade_screen);
    15         mraRatingBar.setRating(4.5f);
    16 //      mraRatingBar.setEnabled(false);
    17         // 设置背景颜色变暗
    18         WindowManager.LayoutParams lp = getWindow().getAttributes();
    19         lp.alpha = 0.7f;
    20         getWindow().setAttributes(lp);
    21         mPopupWindow.setOnDismissListener(new OnDismissListener() {
    22  
    23             @Override
    24             public void onDismiss() {
    25                 WindowManager.LayoutParams lp = getWindow().getAttributes();
    26                 lp.alpha = 1f;
    27                 getWindow().setAttributes(lp);
    28             }
    29         });
    30  
    31     }

     当popupWindow消失后,监听其消失的方法,让背景恢复原样。

  • 相关阅读:
    STM32 ~ 查看系统时钟
    Allegro从.brd文件中导出器件封装
    Cadence原理图与Allegro交互
    Cadence关闭StartPage的方法
    emWin 移植
    python闭包
    python多线程之threading
    3.1决策树算法应用
    3.1决策树算法
    MyEclipse10 配置python的pyDev
  • 原文地址:https://www.cnblogs.com/xiaoliu66007/p/4834316.html
Copyright © 2020-2023  润新知