- 代码声明一个 view:
RelativeLayout rl = new RelativeLayout(getContext());
- 设置 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;