3

画面の上半分だけをマップに表示し、下半分に他のレイアウトを表示しようとしています。テーブルレイアウトと組み合わせて重みを使用すると、これが可能になるはずであることがわかりました。しかし、同じ XML コードは、say ボタンでは完全に機能しますが、マップでは機能しません。
スクリーンショットはこちら.

XML コード:

<TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1" 
        >
            <com.google.android.maps.MapView
            android:id="@+id/map2"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:apiKey="0_z4IHjB6EnXohnoyoudontgoVmhg"
            android:clickable="true" >
        </com.google.android.maps.MapView>

    </TableRow>

    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1" >
        <Button android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="SECOND"></Button>

    </TableRow>

    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1" >
        <Button android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="SECOND"></Button>
    </TableRow>
</TableLayout>

Mapview ブロックをボタンで置き換えると、スクリーンショットの最初の画像のようになりますが、現在は 2 番目の画像のように見えます。
どちらの場合も、重みパラメーター、layout_width、または高さを変更しませんでしたが、何らかの理由でサイズが変更されました。MapView で画面の半分だけをカバーするにはどうすればよいでしょうか?

4

1 に答える 1

7

申し訳ありませんが、Urban さん、ご迷惑をおかけしました - 以前にこれを見たことがあり、マップ サイズを制限できる唯一の方法はプログラムでしたが、その後、このタイプのレイアウトでそれを行いました。

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

 <FrameLayout android:id="@+id/map_frame"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_weight="0.7" >     

    <com.google.android.maps.MapView
        android:id="@+id/map_view" 
        android:layout_width="fill_parent"
        android:layout_height="match_parent" 
        android:enabled="true" 
        android:clickable="true"             
        android:apiKey="dgvbdj_my_secret_key_nvc8mxcksos"/>

 </FrameLayout>

 <co.uk.mycompany.ui.MapNavBar
    android:id="@+id/map_nav"
    android:layout_width="fill_parent"
    android:layout_height="70dip"
    android:layout_gravity="bottom"
    android:layout_weight="0.3" /> 

表示されている最後の項目はカスタム ウィジェットですが、レイアウトには関連する原則が表示されている必要があります。これにより、マップの高さが制限されましたが、幅いっぱいに広げることができました。

于 2011-11-12T20:10:05.277 に答える