【问题标题】:Android MapView half-screen white errorAndroid MapView 半屏白色错误
【发布时间】:2012-02-20 19:51:03
【问题描述】:

我在 Android 中使用 MapView 时遇到了一个奇怪的问题。

在我单击叠加项目然后返回之前,它工作正常。正如您在屏幕截图中看到的那样,地图是半白色的,并且一直如此,直到我放大和缩小并且一切恢复正常。

其他人以前见过这个吗?可能是因为我的布局中的某些东西?

编辑
我发现这个问题与我启动的 Activity 中有一个 MapView 有关。不知何故,当我回来时,MapView 的高度似乎被缓存了。尝试使地图视图无效并重新加载,但没有任何效果。一定有人以前见过这个错误吗?


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

    <com.google.android.maps.MapView
        android:id="@+id/MapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true"
        android:apiKey="xxx"
        android:clickable="true"
        android:enabled="true"
         />

    <include
        android:id="@+id/Progress"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        layout="@layout/progress"
        android:visibility="gone" />

</RelativeLayout>

【问题讨论】:

  • 为什么同时设置了 alignParentBottom 和 alignParentTop 属性?没有设置它们应该是全屏的。
  • 是的,没错,将它们添加到测试中......但没有......

标签: android android-mapview


【解决方案1】:

问题与 MapView 在活动之间切换时重用布局有关。

通过在 onResume 中执行以下操作解决:

LayoutParams layoutParams = mMapView.getLayoutParams();
mMapView.setLayoutParams(layoutParams);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-05
    • 2014-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多