@@ -0,0 +1,3028 @@
+package com.wx.android.common.util;%0A%0Aimport android.content.Context;%0Aimport android.graphics.PixelFormat;%0Aimport android.os.Build;%0Aimport android.view.Gravity;%0Aimport android.view.View;%0Aimport android.view.WindowManager;%0A%0A/**%0A * @author fengwx%0A */%0Apublic class WindowUtils %7B%0A%0A    private static WindowManager mWindowManager;%0A%0A    private static WindowManager getWindowManager(Context context) %7B%0A        if (mWindowManager == null) %7B%0A            mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);%0A        %7D%0A        return mWindowManager;%0A    %7D%0A%0A    private static WindowManager.LayoutParams createDefaultLayoutParams() %7B%0A        WindowManager.LayoutParams params = new WindowManager.LayoutParams();%0A%0A        int type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;%0A        if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.KITKAT) %7B%0A            type = WindowManager.LayoutParams.TYPE_TOAST;%0A        %7D%0A        params.type = type;%0A        params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL%0A                %7C WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE%0A                %7C WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;%0A        params.format = PixelFormat.TRANSLUCENT;%0A%0A        params.width = WindowManager.LayoutParams.MATCH_PARENT;%0A        params.height = WindowManager.LayoutParams.MATCH_PARENT;%0A%0A        params.gravity = Gravity.CENTER;%0A        return params;%0A    %7D%0A%0A    /**%0A     * Adds a child view with the specified layout parameters.%0A     *%0A     * @param context%0A     * @param view%0A     */%0A    public static void addView(Context context, View view) %7B%0A        addView(context, view, createDefaultLayoutParams());%0A    %7D%0A%0A    /**%0A     * Adds a child view with the specified layout parameters.%0A     *%0A     * @param context%0A     * @param view%0A     * @param params%0A     */%0A    public static void addView(Context context, View view, WindowManager.LayoutParams params) %7B%0A        if (context == null %7C%7C view == null) %7B%0A            throw new IllegalArgumentException(%22argument cannot be null.%22);%0A        %7D%0A        mWindowManager = getWindowManager(context);%0A        mWindowManager.addView(view, params);%0A    %7D%0A%0A    /**%0A     * Removes a view during layout.%0A     *%0A     * @param context%0A     * @param view%0A     */%0A    public static void removeView(Context context, View view) %7B%0A        if (context == null %7C%7C view == null) %7B%0A            throw new IllegalArgumentException(%22argument cannot be null.%22);%0A        %7D%0A        mWindowManager = getWindowManager(context);%0A        mWindowManager.removeView(view);%0A    %7D%0A%0A    /**%0A     * Update a view by params%0A     *%0A     * @param context%0A     * @param view%0A     * @param params%0A     */%0A    public static void updateView(Context context, View view, WindowManager.LayoutParams params) %7B%0A        if (context == null %7C%7C view == null %7C%7C params == null) %7B%0A            throw new IllegalArgumentException(%22argument cannot be null.%22);%0A        %7D%0A        mWindowManager = getWindowManager(context);%0A        mWindowManager.updateViewLayout(view, params);%0A    %7D%0A%0A%7D%0A

add window utils