首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >FragmentDialog中的Android Google Map被对话框自己的灰色覆盖所覆盖

FragmentDialog中的Android Google Map被对话框自己的灰色覆盖所覆盖
EN

Stack Overflow用户
提问于 2015-06-14 00:28:37
回答 2查看 1.1K关注 0票数 2

我刚刚将MapView从Activity的布局迁移到了DialogFragment。这是一次相当轻松的迁移:

活动上的按钮将启动对话框,设置地图所需的LatLng

代码语言:javascript
复制
case R.id.btn_open_map:
                android.support.v4.app.FragmentManager fragmentManager
                        = getSupportFragmentManager();
                DirectionsMapDialogFragment mapDialogFragment = new DirectionsMapDialogFragment();
                mapDialogFragment.setLatLng(mLatLng);
                mapDialogFragment.setRetainInstance(false);
                mapDialogFragment.show(fragmentManager, "fragmentName");
            break;

在片段本身中,它都是非常标准的代码。但是,我使用了一个自定义布局,因为我在地图上有一个按钮,可以启动GoogleMaps应用程序:

代码语言:javascript
复制
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true"
    tools:context="com.alexrafa.meetmi.fragments.DirectionsMapFragment"
    android:background="@android:color/transparent">

    <com.google.android.gms.maps.MapView
        android:id="@+id/mv_location_map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clickable="true"
        android:apiKey="APIKEY"
        />

    <ImageButton
        android:layout_width="39dp"
        android:layout_height="39dp"
        android:src="@drawable/ic_directions_grey600_24dp"
        android:id="@+id/btn_directions"
        android:background="@drawable/background_map_button"
        android:layout_gravity="top|center|right"
        android:layout_marginRight="11dp"
        android:layout_marginTop="60dp"
        android:contentDescription="@string/btn_get_map_directions" />

</FrameLayout>

注意我是如何在FrameLayout中将背景设置为透明的。我这样做是因为我的地图似乎被Android中所有Dialog的标准灰色覆盖所覆盖:

而且这也不是API身份验证的问题,所有的map函数都能完美地工作。我该如何解决这个问题呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-06-14 01:50:13

这就是我如何解决我的小困境的:

我为对话框设置了一个主题,特别是mapDialogFragment.setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Light_Panel);

并在布局中添加了一些顶部和底部填充。结果是:

非常感谢saurabh1489帮我找到了答案!

票数 2
EN

Stack Overflow用户

发布于 2018-06-05 03:14:26

代码语言:javascript
复制
DialogFragmentUbicacion nd= new DialogFragmentUbicacion();            nd.setStyle(android.support.v4.app.DialogFragment.STYLE_NORMAL,R.style.MyStyle);
            nd.show(getSupportFragmentManager(),null);
票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30820947

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档