SlidingDrawer over GoogleMap
Asked Answered
C

1

11

First of all, I know the SlidingDrawer is deprecated, but I haven't found any alternative to it so I'm using it anyways :3 (If someone knows an alternative to it, please share it!)

So I have a GoogleMap in my activity (actually a fragment but it doesn't matter), and a nice SlidingDrawer in the same screen. It works fine, but when I open or close the slidingdrawer over the map, it starts behaving weird. It looks like the map want's to stay in front of the slidingdrawer. When the drawer is fully opened, then it comes back to the front and everything is ok.

Is there a workaround for this? I am getting crazy!

here is my layout:

<RelativeLayout 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:id="@+id/window"
    >
        <fragment
            android:id="@+id/hackedmap"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            class="com.google.android.gms.maps.SupportMapFragment" />

<SlidingDrawer
        android:id="@+id/drawer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:content="@+id/drawercontent"
        android:handle="@+id/drawerhandle"
        android:orientation="horizontal" 
        >

        <LinearLayout
            android:id="@id/drawerhandle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00000000"
            android:gravity="center" >

            <ImageView
                android:id="@+id/slidingHandle"
                android:layout_width="40dp"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:scaleType="fitEnd"
                android:src="@drawable/sliding_handle" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/drawercontent"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="#DD000000"
            android:gravity="center_horizontal|top"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/selectednet"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_margin="4dp"
                android:text="Select a network:"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#02bceb" />

            <ListView
                android:id="@+id/passivelist"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:choiceMode="singleChoice" >
            </ListView>
        </LinearLayout>
    </SlidingDrawer>

</RelativeLayout>
Cymogene answered 15/3, 2013 at 12:49 Comment(2)
Any luck with this one? I have the same issue and it reproduces only when using Google Maps V2. It's fine on V1.Dry
I changed the slidingdrawer and used a slidingmenu instead. Hope it helpsCymogene
D
56

Put the map inside of a relative layout. In front of the map a view with the same measure.

Example:

<RelativeLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content" >

                            <include
                                android:layout_width="wrap_content"
                                android:layout_height="250dp"
                                android:layout_weight="1"
                                layout="@layout/general_map_fragment" />

                             <View
                                 android:id="@+id/imageView123"
                                 android:layout_width="match_parent"
                                 android:layout_height="250dp"
                                 android:background="@color/transparent" />


                        </RelativeLayout>
Dominiquedominium answered 26/4, 2013 at 8:29 Comment(7)
Thank you. This completely worked for me. This should be the accepted workaround answer.Duel
This also worked for me. I was having issues with the SupportMapFragment drawing over the drawer in a DrawerLayout. This fixed the issue on Android 2.3 and remained compatible with Android 4.0+!Plaster
Omg, I don't know where did you come up with this answer but million thanks.Torrefy
Really , I don't know how you apply this and find the solution but its tricky. Thanks a lot for grate answer :)Homologue
I dont understand this - can someone explain: I have this code in my map_test.xml pastebin.com/XXEQhS4hNaumachia
awesome answer! you can't imagine how many hours i have spent in this issue! thanks a ton :) btw i have used a FrameLayout instead of RelativeLayout and works too!Bathometer
Can i upvote ten times? Thank you very much. It's works very well.Chromium

© 2022 - 2024 — McMap. All rights reserved.