如何禁用通知栏?

时间:2013-04-23 10:23:05

标签: android android-notification-bar

我想使用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);

1 个答案:

答案 0 :(得分:1)

只需添加到您的清单:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"