我正試圖讓地圖只填充屏幕的上半部分和下半部分的其他一些佈局。現在我知道這應該可以使用權重結合tablelayout。但是同一段XML代碼與所說的按鈕完美匹配,但與地圖無關。
Screenshots here。將MapView限制爲屏幕的一半
的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塊的說一個按鈕,它看起來就像在截圖的第一形象,而現在它看起來像第二一。
在這兩種情況下,我沒有更改任何重量參數或layout_width或height,但它以某種方式更改大小。任何想法如何讓MapView只覆蓋一半的屏幕?
我認爲唯一的方法是以編程方式進行。 –
以及這將如何完成? – Urban
您不要在'TableLayout'和'TableRow'中使用'layout_width'和'layout_height'。切換到嵌套'LinearLayouts',或者使用'RelativeLayout',或者其他東西。 – CommonsWare