したい:
- 以下を含むフラグメントを画面に表示します。
- WebView
- ...完全な高さまで拡張
- 上下の固定サイズのレイアウトに埋め込まれています
- レイアウトをスクロールします (つまり、フルハイトの Web ビューを含む全体)
これは不可能に思えます。SOに関する10以上の異なる質問/回答を読みました.それらはすべて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>