Transparent Google Map on PopupWindow?

偶尔善良 提交于 2019-12-10 11:37:52

问题


I have used a Google Maps (V2) in a PopupWindow and when I run the application, the map is not displayed. Even the area where it should be is fully transparent and I can see the activity below the PopupWindow through it.

Any idea why this is?

Fragment inside popup_window.xml

<fragment
    android:id="@+id/popup_alert_map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/popup_alert_description"
    android:layout_marginTop="10dp"
    class="com.google.android.gms.maps.SupportMapFragment" />

And how I show it inside Popup.java

SupportMapFragment supportMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.popup_alert_map);
locationMap = supportMapFragment.getMap();

locationMap.setMyLocationEnabled(true);
locationMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);

I have another Activity with a map it it and that displays nicely.

Any help greatly appreciated...


回答1:


If you are using the SupportMapFragment then you should use the SupportFragmentManager, like this:

locationMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.popup_alert_map)).getMap();

Try this, tell me what the result.




回答2:


It seems to be a bug, either in Android or in the MapFragment/SupportMapFragment. I tried the same thing (adding the Google Map fragment in a PopupWindow) and on a Google Nexus 10 with Android 4.4, and the map appeared on the PopupWindow just fine, but on an older device with Android 4.0.3 it showed the transparency problem.

Eventually what I did was just move it to another Activity. I looked for as many ways as I could to fix it but it all seems like a dead end, especially given the fact that it works on the newest version of Android without any problems.



来源:https://stackoverflow.com/questions/15873511/transparent-google-map-on-popupwindow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!