在安卓开发中,通常我们可以看到一个视图弹出时,当前Activity界面会变暗,在触摸视图以外的区域时,Activity界面还原亮度的效果,其实这是通过改变当前Window(窗口)的属性来实现的。下面是结合popWindow实现的效果图以及Window的部分源码:
屏幕变暗 变亮效果图 | |
---|---|
![]() |
Window设置屏幕明暗属性的部分源码:
// The current window attributes.
private final WindowManager.LayoutParams mWindowAttributes =
new WindowManager.LayoutParams();
/**
* Specify custom window attributes. <strong>PLEASE NOTE:</strong> the
* layout params you give here should generally be from values previously
* retrieved with {@link #getAttributes()}; you probably do not want to
* blindly create and apply your own, since this will blow away any values
* set by the framework that you are not interested in.
*
* @param a The new window attribu