2016-08-22 39 views
0

我有一個應用程序與兩個工具欄和web視圖。當用戶在webview中滑動時,頂部工具欄應滑動並隱藏,當他滑動頂部工具欄時,應滑動並顯示,與YouTube應用程序非常相似。webview ocuping整個屏幕,覆蓋工具欄

<?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是覆蓋了工具欄ocupying整個屏幕,它不是滾動

回答

1

關於WebView中涵蓋了工具欄: 按照此tutorial 嘗試移動應用欄佈局裏面查看,或簡單地創建一個content_main.xml文件,並且試着將它包含在視圖中。

製作的WebView它滾動有兩種方法:

1)使用XML的:網頁視圖應該有一個家長是滾動型,如:

 <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> 

2)設置它在代碼:

WebView webView = (WebView) findViewById(R.id.web_view); 
webView.setHorizontalScrollBarEnabled(true); 
webView.setVerticalScrollBarEnabled(true);