1

I have been scratching my head on an issue related to Google MapView where a MapView embedded in an activity is overlapping or staying in the foreground over a fragment that also hosts a SupportMapFragment.

Below is the activity.xml file source

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:background="@color/loginbg">

    <include layout="@layout/tool_bar" android:id="@+id/tbar" />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/tbar">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1">
                <com.google.android.gms.maps.MapView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:id="@+id/map"
                    android:layout_gravity="center">
                </com.google.android.gms.maps.MapView>
            </RelativeLayout>
            <View
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"/>
        </LinearLayout>
        <FrameLayout
            android:id="@+id/fragment_container"
            android:layout_below="@+id/tbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:visibility="visible" >
        </FrameLayout>
    </FrameLayout>
</RelativeLayout>

The fragment_container above is the container where I am loading a fragment that hosts a SupportMapFragment.

Below is the layout of the fragment.xml

<?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:background="@color/ColorPrimaryDarkNew"
    android:gravity="center"
    android:orientation="vertical" >
    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <FrameLayout
            android:id="@+id/map_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >
        </FrameLayout>
        <Button
            android:id="@+id/btnDone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_marginRight="10dp"
            android:layout_gravity="top|right"
            style="@style/BlueButton"
            android:text="Continue"/>
    </FrameLayout>
</LinearLayout>

When I run the app, its showing up as below where top half part of the fragment is getting overlapped by the hosting activities MapView. However one thing I noticed is that the top right button which is part of the fragment is showing up correctly.

https://i.stack.imgur.com/KkDry.png

Any help in this regard would be highly appreciated.

Below is the maps library version I am using

compile 'com.google.android.gms:play-services-maps:9.2.1'

neeraj
  • 23
  • 2
  • can you change the fragment_container to the outer layout? – lal Apr 04 '17 at 06:06
  • Thank you lal for taking interest in the question, I have tried moving the fragment_container in the outer layout. However, the result is just the same. – neeraj Apr 04 '17 at 06:10
  • Why are you displaying 2 mapviews on the same screen? If you have a mapview in the main layout then why is fragment_container also holding it? Your layout looks complicated. Can you tell what are you trying to make? What output you want? – Aishwarya Tiwari Apr 04 '17 at 07:18
  • @AishwaryaTiwari I am trying to have two screens in the app, the first will be a big map where I can add a marker and a second screen that will show a half screen map with the marker selected on first screen... I am not intending to display two maps one below other but two screens, one with full map and another with 50% of screen. – neeraj Apr 04 '17 at 07:35
  • Move the 2nd FrameLayout outside the 1st one and let me know the result. Also, what is this for?? '' – Aishwarya Tiwari Apr 04 '17 at 08:44
  • @AishwaryaTiwari I have already tried that as already suggested, same result. "" is for making the child layouts of equal height – neeraj Apr 04 '17 at 09:05
  • Have tried a solution from [here](http://stackoverflow.com/questions/19314383/android-mapview-overlaps-drawerlayout), however could not get it to work... The same issue persists – neeraj Apr 04 '17 at 11:57

0 Answers0