【问题标题】:WebView inside RecyclerView, scrolling issueRecyclerView中的WebView,滚动问题
【发布时间】: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


【解决方案1】:

我对 im.delight.android.webview.AdvancedWebView 有同样的问题。我最终找到了解决方案。 这个选项帮助了我:

isFocusable = false
isFocusableInTouchMode = false

我希望他们也能帮助你。

【讨论】:

    【解决方案2】:

    WebViews 支持滚动,不应该放在 RecyclerView 中,尝试将 WebView 放在 RecyclerView 之外

    【讨论】:

      猜你喜欢
      • 2019-03-05
      • 1970-01-01
      • 1970-01-01
      • 2020-11-30
      • 1970-01-01
      • 1970-01-01
      • 2017-05-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多