使用所有最新的库。我在CoordinatorLayout片段中有一个简单的WebView。当用户向下滚动时尝试隐藏工具栏。
<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:id="@+id/clRootHome"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.bytefury.deliverzz.fragment.HomeFragment">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
android:theme="@style/AppTheme.AppBarOverlay">
<include layout="@layout/toolbar" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/srlHome"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<im.delight.android.webview.AdvancedWebView
android:id="@+id/frag_wv_wv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="insideOverlay" />
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
但是,这根本不做任何事情。滑动以刷新效果很好。
绝望的是,当我切换NestedScrollView和SwipeRefreshLayout时,我得到了一个空白的白色屏幕。
如果您希望工具栏可滚动,则将布局重构为
<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:id="@+id/clRootHome"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.bytefury.deliverzz.fragment.HomeFragment">
<include layout="@layout/toolbar" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/srlHome"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<im.delight.android.webview.AdvancedWebView
android:id="@+id/frag_wv_wv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="insideOverlay" />
</android.support.v4.widget.SwipeRefreshLayout>
现在,将此添加到您的工具栏布局。
app:layout_scrollFlags="scroll|enterAlways"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句