首页 > 解决方案 > 半谷歌地图在片段中可见

问题描述

我的活动中有两个片段。第一个显示项目列表,第二个片段显示谷歌地图。当我点击谷歌地图选项卡时,谷歌地图是可见的,但只有一半区域。上半年地图可见,但下半年只有黑色部分。虽然它覆盖了完整的区域。当我触摸并投掷黑色区域时,我的地图也会投掷。这意味着黑色区域也是地图的一部分。

这个问题并非在所有手机中都存在。它仅在联想等少数手机中使用。我还仅在活动中检查相同的地图实现(不使用片段)并且它工作正常。

看看截图。
谷歌地图片段

我还发现一件事,当我点击搜索框时,我的地图开始正常显示。

谷歌地图片段右一

看看 fragment_map.xml

 <?xml version="1.0" encoding="utf-8"?>
    <layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        tools:context="mypackageName.MyActivity">

        <data>

            <import type="android.view.View" />

            <variable
                name="viewModel"
                type="mypackage.map.googlemap.GViewModel" />
        </data>
      <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:minHeight="@dimen/_600DP">

        <fragment
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <ProgressBar
            android:id="@+id/progress"
            style="?android:attr/progressBarStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true" />
    </RelativeLayout>

    </layout>

标签: androidgoogle-mapsandroid-fragmentsgoogle-maps-android-api-2

解决方案


推荐阅读