我已经实现了浮动
Toolbar
WebView
,准确地说,这些粘在底部。我注意到当我调整尺寸的时候
由于
工具栏
偏移量更改如下:
appBarLayout.addOnOffsetChangedListener(this);
@Override
public final void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
boolean scrollFlagsSet = ((AppBarLayout.LayoutParams) getToolbar().getLayoutParams()).
getScrollFlags() != 0;
int bottom = (!scrollFlagsSet ? 0 : getToolbarHeightAttr()) + verticalOffset;
swipeRefreshLayout.setPadding(0, 0, 0, bottom);
swipeRefreshLayout.requestLayout();
}
swipeRefreshLayout
网络视图
网络视图
而且它非常高效,没有延迟(编辑:在旧设备上有点延迟)。但是当
加载站点时,某些视图粘贴到底部,当发生调整大小时,这些视图将闪烁。我甚至可以在底部的间隙看到文本
网络视图
s边(向下滚动时出现间隙,向上滚动时在底部剪切视图)。我在屏幕上看到了这种行为(蓝色-
工具栏
网络视图
,浅蓝色和橙色-在webview视图中粘贴到底部)。看起来只有几毫秒(一帧?)回到底部固定位置。怎么解决这个问题?
在Chrome或Firefox中加载的同一页面行为正确,这些视图被粘贴到底部并具有固定的位置,不会随着滚动条/工具栏偏移量的变化而闪烁
this
NestedWebView
. 我的应用程序使用了大量加载到
Activities
,它们都在扩展抽象
BaseActivity
CoordinatorLayout
.
WebViews
属于碎片,放在不同的容器中,没有放置的选项
直接进入
协调人布局
编辑:XMLs
活动:
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main_cooridnator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout
android:id="@+id/activity_main_content_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white" />
碎片:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/fragment_webview_swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<my.package.widgets.web.NestedWebView
android:id="@+id/fragment_webview_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="outsideOverlay" />