I have an app with two toolbars and a webview. When the user slides up in the webview the top toolbar should slide and hide, when he slides down the top toolbar should slide and show, much like the youtube app does.
<?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>
Currently the webview is covering the toolbars ocupying the whole screen and it's not scrollable
Regarding the WebView covering the toolbar: Follow this tutorial Try moving the Views inside App bar layout, or simply create a content_main.xml and see try including it in the view.
Making a WebView it scrollable has two methods:
1) Use XML's: Webview should have a parent that is scrollview like :
<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) Set it up in code :
WebView webView = (WebView) findViewById(R.id.web_view);
webView.setHorizontalScrollBarEnabled(true);
webView.setVerticalScrollBarEnabled(true);