4

だから私はダイアログとして表示したいウェブビューを持っています。webview のコンテンツの量に関係なく、その下のボタンを除いて、webview を画面全体に表示したいと思います。現在、私の webview は、ボタンを画面から押し出すのに十分なだけダイアログを埋めています。これはかなり簡単なことだと思いますが、私の人生では、レイアウト、ビュー、および属性値の魔法のような組み合わせを見つけて、うまく機能させることができませんでした. 明確にするために、ボタンがwebviewの上に浮かぶようにしましたが、それが理にかなっている場合は、webviewをボタンのすぐ上で停止してスクロールしたいと思います。

<RelativeLayout android:id="@+id/RelativeLayout01" 
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                xmlns:android="http://schemas.android.com/apk/res/android">
  <WebView android:id="@+id/webview"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           /> 
  <Button android:text="Ok" 
          android:id="@+id/btnOk" 
          android:layout_width="120px" 
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:layout_alignParentBottom="true"
          />
</RelativeLayout>
4

1 に答える 1

8

ウェブビューには android:layout_above="@+id/btnOk" を使用し、ウェブビューの幅と高さには fill_parent を使用します。

ただし、1.5 以下では、正しく認識されるように xml で RelativeLayout ビューを指定する必要があることに注意してください。ボタンを参照します。これは 1.6 または 2.0 で変更されたと思いますが、どちらが正しいかはわかりません。

<RelativeLayout android:id="@+id/RelativeLayout01" 
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                xmlns:android="http://schemas.android.com/apk/res/android">

  <Button android:text="Ok" 
          android:id="@+id/btnOk" 
          android:layout_width="120px" 
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"/>
    <WebView android:id="@+id/webview"
           android:layout_above="@+id/btnOk"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           /> 
</RelativeLayout>
于 2009-11-05T03:57:08.763 に答える