【发布时间】:2017-02-26 17:48:23
【问题描述】:
我正在制作一个应用程序,并且我在 Activity 中使用片段,我正在使用替换功能切换这些片段。这里的问题出在 WebViewFragment 上,当用其他 WebViewFragment 替换现有的 WebViewFragment 时,有时系统导航栏会变白...
应用程序屏幕,从左到右:正常、错误、错误:
这是我的布局
活动
<?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 作为根布局的自定义布局并遇到了同样的问题
层次查看器没有显示任何异常
左OK,右错误:
在设备上导航栏显示为白色,而在层次查看器上显示正确,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 上
【问题讨论】:
-
在 DecorView 上使用请求布局的另一种方式,请参见此处:stackoverflow.com/a/40246099/5823014
标签: android android-layout android-fragments webview navigationbar