3

我正在做一個應用程序,我在一個活動中使用片段,我用替換函數切換這個片段。這裏的問題是與WebViewFragments,與其他替代現有WebViewFragment時,有時系統導航欄變成白色......Android的 - WebViewFragment和NavigationBar

應用程序的屏幕,從左至右依次爲:正常,誤差,誤差:

App screens, from left to right: Normal, error, error

這是我的佈局

活動

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical"> 

    <include layout="@layout/toolbar"/> 

    <android.support.v4.widget.DrawerLayout 
     android:id="@+id/drawerLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <FrameLayout 
      android:id="@+id/contentPanel" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"/> 

     <android.support.design.widget.NavigationView 
      android:id="@+id/navigationView" 
      android:layout_height="match_parent" 
      android:layout_width="wrap_content" 
      android:layout_gravity="start" 
      android:background="?colorAccent" 
      app:itemTextColor="@drawable/navigation_items_color_selector" 
      app:menu="@menu/menu_navigation" 
      style="@style/NavigationDrawerStyle"/> 

    </android.support.v4.widget.DrawerLayout> 
</LinearLayout> 

我使用機器人WebViewFragment所以沒有佈局有由我定義的,我試着用web視圖爲根佈局的自定義佈局,並得到了同樣的問題

層級查看器不顯示任何異常

左行,右錯誤:

Left OK, Right Error

在設備的導航欄顯示的層次觀衆它正確地顯示白色時,該letf圖像是沒有PR會徽,權利有問題,沒有額外的意見。

我使用gradle這個版本2.14.1及以下的支持庫:

  • com.android.support:design:24.2.1
  • com.android.support:appcompat-v7:24.2 0.1
  • com.android.support:recyclerview-v7:24.2.1
  • com.android.support:cardview-v7:24.2.1
  • com.android.support:percent:24.2.1

編輯:忘了提,這種情況發生在Android 7.0和Android 6.0

+0

上DecorView使用要求佈局的另一種方法,請參閱: http://stackoverflow.com/a/40246099/5823014 –

回答

0

這是通過使用layerType作爲LAYER_TYPE_HARDWARE web視圖引起的,它切換到LAYER_TYPE_SOFTWARE解決了這個問題