美文网首页
WindowManager

WindowManager

作者: lotusve_w | 来源:发表于2020-05-15 15:33 被阅读0次

WindowManager 相关

        WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);

        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
        params.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
        params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        params.gravity = Gravity.BOTTOM | Gravity.END;
        params.format = PixelFormat.TRANSLUCENT;
        params.token = view.getWindowToken();     // 注意使用布局中具体的view
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        params.x = 20;    // 单位 px
        params.y = 200;

        windowManager.addView(evaluateView, params);

        // 也可
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
            params.type = WindowManager.LayoutParams.TYPE_PHONE;
        }else{
            params.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
        }

相关文章

网友评论

      本文标题:WindowManager

      本文链接:https://www.haomeiwen.com/subject/rcbcohtx.html