如何隱藏工具欄,滾動網頁流量是什麼時候? 我知道,該webview必須在NestedScrollView和CoordinatorLayout工具欄 - 在AppBarLayout.But我真的不能這樣做。不能老是隱藏工具欄時的WebView滾動
如果有人能幫助我,我將非常感激。
activity_main.xml中
<?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"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/main_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/custom_toolbar_size" />
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/custom_tablayout_size"
android:layout_gravity="bottom"
android:background="@color/toolbarColor"
app:tabIndicatorHeight="0dp"
>
<android.support.design.widget.TabItem
android:id="@+id/ti_arrow_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/ic_arrow_back" />
<android.support.design.widget.TabItem
android:id="@+id/ti_arrow_forward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/ic_arrow_forward" />
<android.support.design.widget.TabItem
android:id="@+id/ti_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/ic_update" />
<android.support.design.widget.TabItem
android:id="@+id/ti_inset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/ic_inset" />
<android.support.design.widget.TabItem
android:id="@+id/ti_star"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:icon="@drawable/ic_star_border" />
</android.support.design.widget.TabLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/custom_tablayout_size"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/custom_toolbar_size"
android:background="@color/toolbarColor"
android:paddingTop="2dp"
app:layout_scrollFlags="scroll|enterAlways" />
看到這個:http://stackoverflow.com/questions/28770530/how-to-hide-actionbar-toolbar-while-scrolling-down-in-webview –
@HtmlTosin我看過它,但它doesn'幫助我。我已經嘗試了幾次 – Ilya
然後你應該使用onScrollListener並手動隱藏工具欄 –