【发布时间】:2013-04-23 18:47:15
【问题描述】:
我想使用en 禁用通知栏,但是当我尝试将此代码放在主 Activity 的 OnCreat 方法中时,我遇到了一些问题。我不知道在<height of the status bar> 中输入什么,params 是什么我试图输入handleParams,我遇到了一些问题和使用问题
context.getWindow().addView(view, params);未知,我无法使用context.getWindow()
View disableStatusBar = new View(context);
WindowManager.LayoutParams handleParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.FILL_PARENT,
<height of the status bar>,
// This allows the view to be displayed over the status bar
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
// this is to keep button presses going to the background window
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,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP;
context.getWindow().addView(view, params);
【问题讨论】:
标签: android android-notification-bar