ScrollView中的WebView可防止所有滚动

Ada*_*dam 2 android webview

我想要:

  1. 在屏幕上放置一个片段,其中包含:
    1. 一个WebView
    2. ......扩大到全高
    3. 嵌入在上下固定大小的布局中
    4. 滚动布局(即整个内容,包括全高webview)

这似乎不可能.我现在已经在SO上阅读了10多个不同的问题/答案,所有这些都涵盖了Android WebView中的不同关键错误,但它们都没有涵盖这种情况.

似乎(从阅读其他问题,并链接到Android站点上当前未修复的错误):

  1. WebView的高度始终是错误的(未固定的Android 2 - 4:例如高度永远不会降低)
  2. WebView的滚动中断,不间断,在连续的Android版本中以新的方式重新打破(例如:一些版本ScrollView控制,其他WebView控制,其他人"战斗",你得到口吃等)
  3. 你必须对ScrollView进行一些奇怪的调整,使它能够做到开箱即用的功能.例如"android:fillViewport ="true"(嗯?这究竟不是"layout_height = fill_parent"应该做什么?)

有没有人有工作代码来实现这个相对简单和常见的设置?我会对任何有用的东西感兴趣(当然除了"扔掉你的Android应用程序并编写一个webapp".这可能有效,但遗憾的是不切实际)

作为参考(和任何其他尝试类似的东西)这里是我的布局,填充屏幕,但所有滚动都被禁用,无缘无故我可以看到:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"
>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <!-- page header -->

        <RelativeLayout
            android:id="@+id/fragment_detailspage_titletext_layout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:visibility="visible" >

            <include
                android:id="@+id/fragment_detailspage_titletext_include"
                layout="@layout/include_textheader"
                android:visibility="visible" />
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/fragment_detailspage_header_layout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/fragment_detailspage_titletext_layout"
            android:clickable="true"
            android:visibility="visible" >

            <!-- logo image -->

            <include
                android:id="@+id/fragment_detailspage_logoimageheader_include"
                layout="@layout/include_logoimageheader" />
        </RelativeLayout>

        <!-- page footer -->

        <RelativeLayout
            android:id="@+id/fragment_detailspage_footer_layout"
            android:layout_width="fill_parent"
            android:layout_height="64dp"
            android:layout_alignParentBottom="true"
            android:background="@drawable/generic_button_not_pressed"
            android:clickable="true"
            android:visibility="visible" >

            <!-- 1 buttons -->

            <include
                android:id="@+id/fragment_detailspage_bottombuttonstrip1_include"
                android:layout_width="wrap_content"
                android:layout_height="64dp"
                android:layout_centerHorizontal="true"
                layout="@layout/include_bottombuttonstrip1" />
        </RelativeLayout>

        <!-- page content -->

        <WebView
            android:id="@+id/fragment_detailspage_content_web"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_above="@id/fragment_detailspage_footer_layout"
            android:layout_below="@id/fragment_detailspage_header_layout"
            android:visibility="visible" />

    </RelativeLayout>

</ScrollView>
Run Code Online (Sandbox Code Playgroud)

Dmy*_*lyk 5

对不起下面的图片,但我想象每次,当有人想在可滚动视图中放置可滚动视图时.

在此输入图像描述

请尝试使用CustomScrollView并覆盖onInterceptTouchEvent:

public class CustomScrollView extends ScrollView {

    public CustomScrollView(Context context) {
        super(context);
    }

    public CustomScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomScrollView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent e) {
        super.onInterceptTouchEvent(e);
        return false;
    }


}
Run Code Online (Sandbox Code Playgroud)