2016-08-22 81 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);