Android - WebViewFragment和NavigationBar

时间:2016-10-17 16:40:32

标签: android android-layout android-fragments webview navigationbar

我正在创建一个应用,并且我在一个Activity中使用片段,我使用replace函数切换这个片段。这里的问题是WebViewFragments,当用其他方法替换现有的WebViewFragment时,系统导航栏变为白色...

应用程序屏幕,从左到右:正常,错误,错误:

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>

我使用了androids WebViewFragment所以没有我定义的布局,我尝试使用Webview作为根布局的自定义布局并遇到了同样的问题

层次结构查看器没有显示任何异常

左边确定,右边错误:

Left OK, Right Error

在设备上导航栏显示白色,而层次结构查看器显示正确,letf图像没有问题,右边有问题,没有其他视图。

我使用gradle版本2.14.1和以下支持库:

  • com.android.support:design:24.2.1
  • com.android.support:appcompat-v7:24.2.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上

1 个答案:

答案 0 :(得分:0)

这是由webview使用layerType作为LAYER_TYPE_HARDWARE引起的,将其切换为LAYER_TYPE_SOFTWARE解决了问题