Android 开发小技巧

  1. 代码声明一个 view:
RelativeLayout rl = new RelativeLayout(getContext());
  1. 设置 WindowManager.LayoutParams 的透明度:配置 WindowManager.LayoutParams.FLAG_DIM_BEHIND 和 dimAmount
WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams(
    WindowManager.LayoutParams.MATCH_PARENT,
    WindowManager.LayoutParams.MATCH_PARENT,
    WindowManager.LayoutParams.LAST_APPLICATION_WINDOW,
    WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_DIM_BEHIND,
    PixelFormat.TRANSPARENT
);
mLayoutParams.dimAmount = 0.6f;

posted on 2021-06-09 10:42  cag2050  阅读(60)  评论(0编辑  收藏  举报

导航