【发布时间】:2017-03-28 11:37:03
【问题描述】:
我正在尝试让地图仅填充屏幕的上半部分,并在下半部分填充其他一些布局。现在我知道这应该可以结合使用权重和表格布局来实现。但是同一段 XML 代码完美地适用于说按钮,但不适用于地图。
Screenshots here。
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 只覆盖一半屏幕吗?
【问题讨论】:
-
我认为唯一的方法就是以编程方式进行。
-
您不要将
layout_width和layout_height与TableLayout和TableRow一起使用。切换到嵌套的LinearLayouts,或者使用RelativeLayout,什么的。 -
@CommonsWare thx 帮助...我需要停止使用 tablelayout 这么多..
标签: android android-mapview google-maps-mobile