1

私の WebView が非常に大きい場合、コンテンツが非常に大きくても WebView のコンテンツをスクロールできる場合でも、問題はなく、WebView の高さが画面の高さに収まります。しかし、WebView のコンテンツが少ないと、WebView の高さが画面に収まりません。

これは私のレイアウトです:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<ScrollView android:layout_width="fill_parent"
    android:layout_height="fill_parent"
        android:fitsSystemWindows="true">

    <WebView android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fitsSystemWindows="true" />

</ScrollView>

<LinearLayout android:id="@+id/media_player"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:visibility="visible">

    <Button android:textStyle="bold"
        android:id="@+id/ButtonPlayStop"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:drawable/ic_media_play" />

    <SeekBar android:id="@+id/SeekBar"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_below="@id/ButtonPlayStop" />

</LinearLayout>

スクリーンショットは次のとおりです。

ここに画像の説明を入力

誰でもこの問題を解決するのを手伝ってくれますか?

4

1 に答える 1

8

コンテンツがビューの境界よりも大きい場合にスクロールする方法を既に認識しているため、 a のWebView内側に aを配置する必要はありません。ScrollViewスクロール ビューを他のスクロール ビュー内に配置すると、望ましくない動作が発生する傾向があります。

それを一瞬無視しても、 a のScrollView内容が小さすぎる場合、 a は余分な空きスペースを占有するように拡張しません。つまり、特別なフラグ ( android:fillViewport ) が使用されている場合を除きます。

解決策として、外側を取り外して、それ自体でスペースを占有ScrollViewしようとします. WebViewをコンテナとして使用するRelativeLayoutと、1 レベルの深さだけでこのレイアウトを取得できます。

  • 再生ボタンは親の左下になります
  • シーク バーは再生ボタンの右下に移動します
  • WebView はfill_parent幅と高さでそれらの上にあります

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    
    <Button android:textStyle="bold"
    android:id="@+id/ButtonPlayStop"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="@android:drawable/ic_media_play" />
    
    <SeekBar android:id="@+id/SeekBar"
    android:layout_toRightOf="@+id/ButtonPlayStop"
    android:layout_alignParentBottom="true"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:layout_below="@id/ButtonPlayStop" />
    
    <WebView android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_above="@id/ButtonPlayStop" />
    
    </RelativeLayout>
    
于 2011-10-10T20:10:42.860 に答える