在DialogActivity中使用时,MapFragment会获得深色叠加

nha*_*man 24 android android-maps-v2

我试图表现出MapFragmentAndroid Maps v2 APIActivity@android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar主题.这很好用.但是,地图会出现黑暗叠加层:

对话

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

正常

这是我的xml布局文件:

<?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>
Run Code Online (Sandbox Code Playgroud)

这里发生了什么?

Aur*_*rel 19

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

  • 在styles.xml中为您的主题添加此参数:
    <item name="android:backgroundDimEnabled">false</item>

不好的部分:它删除了活动背后的黑色叠加层.

  • 在地图对象的顶部设置z顺序:
    GoogleMapOptions googleMapsOptions = new GoogleMapOptions();
    googleMapsOptions.zOrderOnTop( true );
    MapFragment mapFragment = MapFragment.newInstance(googleMapsOptions);

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

Personnaly,我选择了第一个解决方案.
希望这有帮助!

链接到源


Ind*_*Boy 11

用于DialogFragment:

getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
Run Code Online (Sandbox Code Playgroud)