Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

navigation drawer google maps v2 , map blocking drawer

I have this problem when opening drawer on gingerbread and behind is google map v2. Map that should be on screen behind gets on top of everything.

Now I could bypass this by hiding map when drawer opens and show it when closes but I'm looking for more elegant solution if someone came up with any?

Map overlaying navigation drawer

like image 969
Bojan Avatar asked Jul 18 '13 20:07

Bojan


People also ask

How to make custom navigation drawer in android?

Android App Development for BeginnersStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. Step 3 − Add the following code to res/layout/nav_header_main.

What is a navigation drawer?

The navigation drawer is a UI panel that shows your app's main navigation menu. The drawer appears when the user touches the drawer icon in the app bar or when the user swipes a finger from the left edge of the screen.


2 Answers

Just wrap SupportMapFragment with FrameLayout and put transparent View above like this:

<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <!-- Map fragment -->
        <fragment
            android:id="@+id/map"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            class="com.google.android.gms.maps.SupportMapFragment" />
        <!-- Transparent view -->
        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

Tested with Android 4.0.4 - works fine for me

like image 69
Roman Avatar answered Nov 01 '22 23:11

Roman


There is a bug with google maps api v2 and black space. Maybe you have got similar problem. For solutions look here: https://github.com/jfeinstein10/SlidingMenu/issues/228 and here: https://github.com/jfeinstein10/SlidingMenu/issues/168

As far as I remember solutions are one of this:

  • extending Google Maps and make it to redraw every view more often
  • set map's z index on top param to true
  • put transparent overlay over Google Maps view
like image 44
Malachiasz Avatar answered Nov 01 '22 23:11

Malachiasz