Kak*_*593 5 android webview coordinator-layout android-coordinatorlayout nestedscrollview
我使用support.v4.widget.NestedScrollView,我的webview有问题.
这是我的布局:
<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:focusableInTouchMode="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="@+id/barlayout">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:background="#9E9E9E"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/relativeLayout"
android:animateLayoutChanges="true">
<!-- some views here -->
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<WebView
android:id="@+id/webView"
android:layout_height="match_parent"
android:layout_width="match_parent" />
</android.support.v4.widget.NestedScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/dialog_location"
android:id="@+id/dialog"
android:visibility="invisible"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
有了这个布局,webview必须滚动很多(抱歉链接,我无法发布图片)
https://drive.google.com/open?id=0B7otV-_1sdEvUWRzSjlHY01fY3c
如果我将webview更改为wrap_content,则webview很小
<WebView
android:id="@+id/webView"
android:layout_height="wrap_content"
android:layout_width="match_parent" />
Run Code Online (Sandbox Code Playgroud)
https://drive.google.com/open?id=0B7otV-_1sdEvbVFSRlR0a2IxeUk
我们正在做完全相同的事情。这已被分类给谷歌的开发人员和设计师。目前提供的解决方案是不在 NestedScrollView 中使用 Android webview。
以下是该线程的摘录:
这是WAI。
如果将webview放入NestedScrollView中,高度为wrap_contents,并且webview扩展到页面的大小。这就像在桌面中一样,您将浏览器窗口的大小调整为页面的高度,因此它无法垂直滚动。滚动发生在 NestedScrollView 而不是 webview 本身。
因此,页面中没有 js 会看到任何滚动事件,因此它不知道您已滚动到页面末尾加载更多内容。
此外,硬件层由 GL 纹理支持,并且它们具有最大尺寸(最小的屏幕尺寸,尽管通常不会大很多)。如果视图变得大于最大纹理大小,则它将无法与硬件层一起使用。这适用于任何视图,而不仅仅是 Web 视图。
解决方案:不要将webview放在NestedScrollView中。不要在wrap_contents模式下使用webview。让webview滚动网页本身。
| 归档时间: |
|
| 查看次数: |
2449 次 |
| 最近记录: |