WebView滑動隱藏toolbar

注意
1.AppBarLayout與NestedScrollView的位置關(guān)系
2.toolbar設(shè)置layout_scrollFlags
3.NestedScrollView設(shè)置layout_behavior
4.CoordinatorLayout即最外層父布局設(shè)置background是因為配合滑動返回的windowbackground設(shè)置了透明
更新說明
修改progressbar層級關(guān)系,滑動后還是會隱藏,下次再修改看看效果

<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white">
    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:fitsSystemWindows="true">
    <WebView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/mainWebView3"
        android:focusable="true"
        android:focusableInTouchMode="true"/>
    </android.support.v4.widget.NestedScrollView>
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="46dp"
        android:fitsSystemWindows="true"
        android:background="@color/white">
        <ProgressBar
            style="?android:attr/progressBarStyleHorizontal"
            android:id="@+id/myProgressBar3"
            android:layout_width="match_parent"
            android:layout_height="2dip"
            android:progressDrawable="@drawable/layer"
            app:layout_scrollFlags="scroll|enterAlways"
            />
        <android.support.v7.widget.Toolbar
            android:id="@+id/web3_toolbar"
            android:layout_width="match_parent"
            android:layout_height="44dp"
            android:background="#00000000"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:theme="@style/ThemeOverlay.AppCompat.ActionBar" />
    </android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容