我想要:
- 在屏幕上放置一个片段,其中包含:
- 一个网页视图
- ...扩展至全高
- 嵌入在上下固定大小的布局中
- 滚动布局(即整个内容,包括全高 webview)
这似乎是不可能的。我现在已经阅读了 10 多个关于 SO 的不同问题/答案,所有这些都涵盖了 Android WebView 中不同的关键错误,但没有一个涵盖这种情况。
似乎(通过阅读其他问题,并在 android 网站上关注当前未修复错误的链接):
- WebView 的高度一直是错误的(未修复的 Android 2 - 4:例如高度从不降低)
- WebView 的滚动中断、取消中断、在连续的 Android 版本中以新的方式重新中断(例如:某些版本 ScrollView 获得控制权,其他 WebView 获得控制权,其他他们“战斗”并且你会结结巴巴等)
- 您必须对 ScrollView 进行一些奇怪的调整,以使其能够做到开箱即用。例如“android:fillViewport="true"(嗯?这不正是“layout_height=fill_parent”应该做的吗?)
有没有人有工作代码来实现这个相对简单和常见的设置?我会对任何有效的东西感兴趣(当然除了“扔掉你的 Android 应用程序并编写一个 web 应用程序”。这可能有效,但很遗憾,这是不切实际的)
供参考(以及其他尝试类似操作的人)这是我的布局,它填满了屏幕,但所有滚动都被禁用,我无缘无故地看到:
<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>