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:
When I change the theme to @android:style/Theme.DeviceDefault.Light.NoActionBar
, the map is shown as it should:
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>
What is happening here?
I got the same problem. After some research, I found two hacks :
<item name="android:backgroundDimEnabled">false</item>
Bad part : it removes the black overlays behind the activity.
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 !
Link to the source
For DialogFragment
:
getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With