-
效果
-
源码实现
frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
public final void showSafeModeOverlay() {View v = LayoutInflater.from(mContext).inflate(com.android.internal.R.layout.safe_mode, null);WindowManager.LayoutParams lp = new WindowManager.LayoutParams();lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY;lp.width = WindowManager.LayoutParams.WRAP_CONTENT;lp.height = WindowManager.LayoutParams.WRAP_CONTENT;//lp.gravity = Gravity.BOTTOM | Gravity.START;//修改为居中显示lp.gravity = Gravity.CENTER;lp.format = v.getBackground().getOpacity();lp.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| WindowManager.LayoutParams.FLAG