标签:str touch 问题解决 not addview idt set style rgb
申明:低级码农问题解决中的参考和解决后的小结,仅用于个人记录,能力有限,可能有些错误,缺陷不自知,欢迎在评论中指正,谢谢!
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
android.provider.Settings.canDrawOverlays(Context)
注意,8.0以上,必须使用 TYPE_APPLICATION_OVERLAY
// 找到布局文件 View popup = LayoutInflater.from(getApplicationContext()).inflate(R.layout.popup, null); WindowManager mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); // WindowManager.LayoutParams的参数 WindowManager.LayoutParams mViewParams = new WindowManager.LayoutParams(); mViewParams.width = WindowManager.LayoutParams.WRAP_CONTENT; mViewParams.height = WindowManager.LayoutParams.WRAP_CONTENT; mViewParams.gravity = Gravity.CENTER; DisplayMetrics dm = new DisplayMetrics(); mWindowManager.getDefaultDisplay().getMetrics(dm); mViewParams.x = -(int) dm.widthPixels / 2; mViewParams.y = -(int) dm.heightPixels / 2; // 8.0系统加强后台管理,禁止在其他应用和窗口弹提醒弹窗,如果要弹,必须使用TYPE_APPLICATION_OVERLAY if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { mViewParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; } else { mViewParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; } mViewParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON; mViewParams.format = PixelFormat.RGBA_8888; mViewParams.alpha = 0.5f; mWindowManager.addView(popup, mViewParams);
标签:str touch 问题解决 not addview idt set style rgb
原文地址:https://www.cnblogs.com/hellodingc/p/12623122.html