2015-04-30 135 views
2

我一直在這個問題上撞了我一個星期的頭。各種谷歌搜索顯示可能的解決方案,但沒有奏效Android type_system_overlay沒有覆蓋整個屏幕

我會發佈一個鏈接到我的應用程序,但我相信這是不允許的。 簡單的應用程序:按下按鈕,它激活半透明的彩色覆蓋。

問題:

當疊加被激活,如果導航欄是透明的,它不包括/去導航欄的後面。

示例:您可以看到導航欄未被覆蓋。透明的藍色是覆蓋層。

example of issue.

在主活性超級和設置內容視圖後:

Intent i = new Intent(getApplicationContext(), TintOverlayService.class); 
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); 

TintOverlayService.class

LayoutInflater li = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); 
    windowManager = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE); 
    mTopView = (LinearLayout) li.inflate(R.layout.red_overlay, null, false); 
    mTopView.setBackgroundColor(Color.parseColor(colorCode.replace("#", tintValue))); 

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
      WindowManager.LayoutParams.MATCH_PARENT, 
      WindowManager.LayoutParams.MATCH_PARENT, 
      WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, 
      WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, 
      PixelFormat.TRANSLUCENT);  

Color.parseColor(colorCode.replace("#", tintValue))只用於用戶選擇的顏色和不透明度水平。

XML爲red_overlay佈局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#40370000" 
    android:theme="@android:style/Theme.Holo.NoActionBar.TranslucentDecor" 
    android:fitsSystemWindows="true" 
    > 
</LinearLayout> 

我曾嘗試過各種WindowManager.LayoutParams,佈局,自定義主題,景觀標誌,沉浸式視圖的事情。我現在處於頭痛的狀態。

任何幫助,非常感謝。

+0

一個解決方案是隱藏導航欄。請參考鏈接: https://developer.android.com/training/system-ui/navigation.html – abhishesh

+0

我有同樣的問題。任何新聞? – AnAurelian

+0

不幸的是,我仍然無法弄清楚。 – cfisher

回答

0

我所要做的就是添加兩個標誌的參數:

WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;

int LayoutParamFlags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN 
        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION 
        | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; 

WindowManager.LayoutParams params = new WindowManager.LayoutParams(
        WindowManager.LayoutParams.MATCH_PARENT, 
        densityDpi * 6, 
        WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, 
        LayoutParamFlags, 
        PixelFormat.TRANSLUCENT);