1

I'm displaying a GoogleMap in a RelativeLayout, with a TextView (among other things) over:

<RelativeLayout
    width=match_parent
    height=match_parent>
    <Map
        width=match_parent
        height=match_parent />
    <TextView
        with=100dp
        height=100dp />
</RelativeLayout>

For some reason, if I hit home, then reopen the app, the Map will be over (covering) the TextView.

I tried to use SupportMapFragment, and MapView (with zOrderOnTop="false") but no effect. I also tried to show / hide the Map in onResume / onPause, no effect.

I also had the Drawer issue, but the suggested fix only solved the Drawer problem.

Versions: com.google.android.gms:play-services:4.2.+ compileSdkVersion 19 minSdkVersion 14 targetSdkVersion 14.

Note: this problem only occurs on Samsung Galaxy SII (4.0.4). Any idea? Thanks.

Update: I also tried to inflate the Fragment from the code instead of XML, or use GoogleMapOptions to set zOrderOnTop(false), still same result...

Update 2: I think I narrowed down the problem:

Working:

drawer.xml

<Drawer>
    <RelativeLayout
        width=match_parent
        height=match_parent>
        <RelativeLayout
            width=match_parent
            height=match_parent>
            <Map
                width=match_parent
                height=match_parent>
            <View
                width=match_parent
                height=match_parent
                background=transparent>
        </RelativeLayout>

        <TextView
            width=100dp
            height=100dp>
    </RelativeLayout>

    <ListView /> <!-- menu -->
</Drawer>

Not working:

drawer.xml

<Drawer>
    <FrameLayout /> <!-- fragment container -->

    <ListView /> <!-- menu -->
</Drawer>

map.xml

<RelativeLayout
    width=match_parent
    height=match_parent>
    <RelativeLayout
        width=match_parent
        height=match_parent>
        <Map
            width=match_parent
            height=match_parent>
        <View
            width=match_parent
            height=match_parent
            background=transparent>
    </RelativeLayout>

    <TextView
        width=100dp
        height=100dp>
</RelativeLayout>

One solution would be to have the Map declared in drawer.xml, then use setVisibility to show / hide it when needed... Any better suggestion?

Community
  • 1
  • 1
mbmc
  • 5,024
  • 5
  • 25
  • 53

1 Answers1

0

You should try:

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

    <!-- Extra hack ViewGroup to fix Map z-ordering -->
    <RelativeLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <Map
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <View 
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/transparent"/>

    </RelativeLayout>

    <TextView
        with=100dp
        height=100dp />

</RelativeLayout>

At least for me, this was sufficient to fix issues with the z-order. I believe this issue only effects pre Jellybean devices, which explains why you are seeing it on your SII.

jacobhyphenated
  • 2,105
  • 2
  • 17
  • 27
  • Thanks, but I already tried that. It only fixes the drawer issue, not the main problem... – mbmc Apr 14 '14 at 20:43