2

したい:

  1. 以下を含むフラグメントを画面に表示します。
    1. WebView
    2. ...完全な高さまで拡張
    3. 上下の固定サイズのレイアウトに埋め込まれています
    4. レイアウトをスクロールします (つまり、フルハイトの Web ビューを含む全体)

これは不可能に思えます。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 アプリを破棄して 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>
4

2 に答える 2

1

私が使用するほとんどのアプリには、何らかの形式の Web / スクロール / カスタム ヘッダー/フッター コンボがあります。

TextViewの代わりに「Web」を使用できることWebViewに注意してください。それらのいずれかにより、 -in-a-シナリオから抜け出すことができます. を使用するアプリはほとんどなく、.ListViewScrollViewWebViewWebViewScrollViewScrollViewWebViewScrollView

確かにもっと複雑な可能性があります。たとえば、Gmail の会話ビューは、WebViewを使用して Z 軸上に他のものを重ねたものFrameLayoutであり、おそらく のスクロール イベントを追跡して、そのWebView上に重ねられた他のものの位置を変更します (例: 送信者のピン留め-スクロールして一番上に移動すると、and-reply-button ヘッダーが表示されます)。

uiautomatorviewerAndroid 4.1 以降のデバイスをお持ちの場合は、この種の実装方法を学ぶために使用してください。それが、Gmail がどのように成功しているかを私が見ている方法です。すべての詳細を取得することはできませんが、手がかりが得られます。

于 2013-05-08T21:53:34.670 に答える