我正在开发一个应用程序,其中我想禁用用户端的状态栏,并启用时,由管理员使用。我使用以下代码成功禁用了状态栏:
WindowManager manager= ((WindowManager) getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE));
WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
localLayoutParams.gravity = Gravity.TOP;
localLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
// this is to enable the notification to recieve touch events
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
// Draws over status bar
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
localLayoutParams.height = (int) (50 * getResources()
.getDisplayMetrics().scaledDensity);
localLayoutParams.format = PixelFormat.TRANSPARENT;
// PrefUtils.setKioskModeActive(false, getApplicationContext());
view = new customViewGroup(this);
manager.addView(view, localLayoutParams); 但我不能再次启用状态bar.Is,这可能会使用此代码再次启用。或禁用/启用状态栏的任何其他方式。提前谢谢你!
发布于 2015-07-06 15:05:53
@Kaifi你应该从WindowManager中删除相同的视图,如下所示:
((WindowManager) getApplicationContext().getSystemService(Service.WINDOW_SERVICE)).removeView(YOUR_VIEW);或如下所示:
manager.removeView(YOUR_VIEW);https://stackoverflow.com/questions/31239458
复制相似问题