【发布时间】:2018-07-17 22:51:43
【问题描述】:
我在使用 RecyclerView 项目时遇到了 webView 的问题。 点击 YouTube 视频或 Twitter 帖子后,WebView 会滚动到顶部。 这是我的 WebView 项目布局:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<WebView
android:id="@+id/postDetailItemWebView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
这是显示回收器的 Activity 布局:
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:animateLayoutChanges="true">
<android.support.design.widget.AppBarLayout ..../>
<android.support.v7.widget.RecyclerView
android:id="@+id/postDetailRecycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:layoutAnimation="@anim/linear_recycler_anim"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<RelativeLayout..../>
WebView 内容巨大,超过了屏幕大小,这就是它需要滚动的原因。我已将它放在 RecyclerView 中,因为我还有其他项目,例如:页眉和页脚。是否有任何解决方法,或者我必须将 WebView 放在 RecyclerView 之外作为全屏视图?
【问题讨论】:
-
你得到上述解决方案了吗? @anddev
标签: android html webview android-recyclerview