0

我得到了谷歌地图 api v2 的工作,但是当我选择应用程序时,地图是全屏的。我如何使它变小?特别是设置的宽度和高度以及屏幕位置(左上角)

提前致谢

4

1 回答 1

1

您可以使用布局和 XML 布局文件中的参数来更改大小、位置等。例如,来自 google 的示例代码,用于在屏幕的 4 个象限中显示 4 个地图副本:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:map="http://schemas.android.com/apk/res-auto"
  android:id="@+id/map_container"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">
  <LinearLayout
    android:id="@+id/map_container2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="0.5"
    android:orientation="horizontal">
    <fragment
      android:id="@+id/map1"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_weight="0.5"
      class="com.google.android.gms.maps.SupportMapFragment"
      map:cameraTargetLat="40.72"
      map:cameraTargetLng="-74.00"
      map:cameraZoom="8"/>
    <fragment
      android:id="@+id/map2"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_weight="0.5"
      class="com.google.android.gms.maps.SupportMapFragment"
      map:cameraTargetLat="51.51"
      map:cameraTargetLng="-0.12"
      map:cameraZoom="8"/>
  </LinearLayout>
  <LinearLayout
    android:id="@+id/map_container2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="0.5"
    android:orientation="horizontal">
    <fragment
      android:id="@+id/map3"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_weight="0.5"
      class="com.google.android.gms.maps.SupportMapFragment"
      map:cameraTargetLat="48.85"
      map:cameraTargetLng="2.35"
      map:cameraZoom="8"/>
    <fragment
      android:id="@+id/map4"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_weight="0.5"
      class="com.google.android.gms.maps.SupportMapFragment"
      map:cameraTargetLat="35.69"
      map:cameraTargetLng="139.69"
      map:cameraZoom="8"/>
  </LinearLayout>
</LinearLayout>
于 2013-11-04T22:33:33.140 回答