2015-10-25 39 views
-1
WindowManager manager = ((WindowManager) context.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_KEEP_SCREEN_ON | 

      // Draws over status bar 
      WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; 

    localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; 
     manager.getDefaultDisplay().getHeight(); 
     localLayoutParams.height = (int) (25 * context.getResources() 
       .getDisplayMetrics().scaledDensity); 
    localLayoutParams.format = PixelFormat.TRANSPARENT; 
     view = new customViewGroup(context); 

     manager.addView(view, localLayoutParams); 

由於頂部隱形view,我的應用程序頂部按鈕不會收到click事件。你可以請建議一種方法,我可以禁用status bar,而不禁用應用程序的頂端?禁用狀態欄時,應用程序不會收到點擊

回答

0

改爲使用自定義主題來隱藏狀態欄。在您的styles.xml創建自定義主題:

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat"> 
    <item name="android:windowNoTitle">true</item> 
    <item name="android:windowActionBar">false</item> 
    <item name="android:windowFullscreen">true</item> 
    <item name="android:windowContentOverlay">@null</item> 
</style> 

而只是將它加入你的AndroidManifest.xml:

<application 
... 
... 
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"> 
+0

這種風格隱藏狀態欄,但你仍然可以通過滑動打開它,我需要在我的啓動器應用上禁用該功能。 –

相關問題