我想:
这似乎不可能。我现在已经在SO上阅读了10多个不同的问题/答案,它们都涵盖了Android WebView中的不同关键错误,但它们都没有涵盖这种情况。
似乎(从阅读其他问题,并链接到Android网站上当前未修复的错误):
有没有人有工作代码来实现这种相对简单和常见的设置?我会对任何有用的东西感兴趣(当然除了“扔掉你的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>
答案 0 :(得分: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;
}
}
答案 1 :(得分:1)
我使用的应用程序几乎都有某种形式的Web / Scroll /自定义页眉/页脚组合
请记住&#34; Web&#34;可以是TextView
而不是WebView
,请记住&#34; Scroll&#34;可以是ListView
而不是ScrollView
,请记住&#34;自定义页眉/页脚组合&#34;可以在WebView
内的HTML中实现。任何这些都可以让您摆脱WebView
- in - a - ScrollView
场景。很少有应用会使用ScrollView
,而WebView
中仍会有更少的用户尝试使用ScrollView
。
肯定有更复杂的可能性。例如,Gmail的对话视图是WebView
,其他内容使用FrameLayout
在Z轴上分层,其中可能会跟踪WebView
的滚动事件更改分层顶部的其他内容的位置(例如,在滚动时将发件人和回复按钮标头固定到顶部)。
如果您使用的是Android 4.1及更高版本的设备,欢迎使用 uiautomatorviewer
来了解如何实施此类内容。这就是我如何看待Gmail如何实现这一目标的方式。你无法获得所有细节,但它可以为你提供线索。