Android webview聚焦整个屏幕,覆盖工具栏

Android webview聚焦整个屏幕,覆盖工具栏,android,webview,android-toolbar,slide,Android,Webview,Android Toolbar,Slide,我有一个带有两个工具栏和一个网络视图的应用程序。当用户在webview中向上滑动时,顶部工具栏应该滑动并隐藏,当用户向下滑动时,顶部工具栏应该滑动并显示,就像youtube应用程序一样 <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"

我有一个带有两个工具栏和一个网络视图的应用程序。当用户在webview中向上滑动时,顶部工具栏应该滑动并隐藏,当用户向下滑动时,顶部工具栏应该滑动并显示,就像youtube应用程序一样

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.moover.moover.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true">

        <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/AppTheme.PopupOverlay"
                app:layout_scrollFlags="scroll|enterAlways" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar2"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/AppTheme.PopupOverlay">
                <TextView
                    android:id="@+id/textViewWebPage"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />
            </android.support.v7.widget.Toolbar>

    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rcView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        />

    <WebView  xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />

</android.support.design.widget.CoordinatorLayout>


当前,webview覆盖了整个屏幕上的工具栏,并且它不可滚动

关于覆盖工具栏的webview: 照此 尝试将视图移动到App bar布局中,或者简单地创建一个content_main.xml,然后查看“尝试将其包含在视图中”

使WebView可滚动有两种方法:

1) 使用XML的:Webview应该有一个类似于scrollview的父级:

        <ScrollView 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent">
            <WebView android:id="@+id/web_view" 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"/>
        </ScrollView>

关于覆盖工具栏的WebView: 照此 尝试将视图移动到App bar布局中,或者简单地创建一个content_main.xml,然后查看“尝试将其包含在视图中”

使WebView可滚动有两种方法:

1) 使用XML的:Webview应该有一个类似于scrollview的父级:

        <ScrollView 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent">
            <WebView android:id="@+id/web_view" 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"/>
        </ScrollView>