在DialogActivity中使用时,MapFragment会得到深色覆盖 [英] MapFragment gets a dark overlay when used in DialogActivity

查看:91
本文介绍了在DialogActivity中使用时,MapFragment会得到深色覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在具有@android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar主题的Activity中显示Android Maps v2 APIMapFragment.这很好.但是,地图上有一个深色的叠加层:

I'm trying to show a MapFragment of the Android Maps v2 API in an Activity with the @android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar theme. This works fine. However, the map gets a dark overlay:

当我将主题更改为@android:style/Theme.DeviceDefault.Light.NoActionBar时,该地图将显示为:

When I change the theme to @android:style/Theme.DeviceDefault.Light.NoActionBar, the map is shown as it should:

这是我的xml布局文件:

This is my xml layout file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <fragment
        android:id="@+id/mapfragment"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        class="com.google.android.gms.maps.MapFragment" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="HELLO"
        android:textSize="@dimen/textsize_large" />

</LinearLayout>

这是怎么回事?

推荐答案

我遇到了同样的问题.经过一番研究,我发现了两个黑客:

I got the same problem. After some research, I found two hacks :

  • 在styles.xml中为您的主题添加此参数:
    <item name="android:backgroundDimEnabled">false</item>
  • Add this param for your theme in the styles.xml :
    <item name="android:backgroundDimEnabled">false</item>

不良部分:它会删除活动后面的黑色覆盖层.

Bad part : it removes the black overlays behind the activity.

  • 在顶部为地图对象设置z顺序:
    GoogleMapOptions googleMapsOptions = new GoogleMapOptions();
    googleMapsOptions.zOrderOnTop( true );
    MapFragment mapFragment = MapFragment.newInstance(googleMapsOptions);
  • Set the z order on the top for the map object :
    GoogleMapOptions googleMapsOptions = new GoogleMapOptions();
    googleMapsOptions.zOrderOnTop( true );
    MapFragment mapFragment = MapFragment.newInstance(googleMapsOptions);

不良部分:地图位于缩放"控件和我的位置"按钮上方.

Bad part : The map is above the Zoom control and MyLocation button.

过时的,我选择第一个解决方案.
希望有帮助!

Personnaly, I choose the first solution.
Hope this help !

链接到源代码

这篇关于在DialogActivity中使用时,MapFragment会得到深色覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆