Skip to content Skip to sidebar Skip to footer

Android Mapview With Sliding Menu Obscures Menu

I have a map view for android maps api v2 in an activity that uses this sliding menu https://github.com/iPaulPro/SlidingMenu. The sliding menu works great except for on the map pa

Solution 1:

Found this stack overflow post ViewPager with Google Maps API v2: mysterious black view and used this class in place of the normal map fragment.

package com.myapp.gms.maps;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
import com.google.android.gms.maps.SupportMapFragment;

/**
 * @author btate
 */publicclassTransparentSupportMapFragmentextendsSupportMapFragment {

    publicTransparentSupportMapFragment() {}

    @Overridepublic View onCreateView(LayoutInflater inflater, 
                                 ViewGroup view, 
                                 Bundle savedInstance) {

        Viewlayout=super.onCreateView(inflater, view, savedInstance);
        FrameLayoutframeLayout=newFrameLayout(getActivity());
        frameLayout.setBackgroundColor(
           getResources().getColor(android.R.color.transparent));
        ((ViewGroup) layout).addView(frameLayout,
            newViewGroup.LayoutParams(
               LayoutParams.MATCH_PARENT, 
               LayoutParams.MATCH_PARENT
            )
        );
        return layout;
    }

}

Solution 2:

TransparentSupportMapFragment solved the problem for android 2.3.7 Thank you!

Solution 3:

There is one more solution to this problem. I am showing MapFragment within another fragment. The MapFragment is dynamically added into the a FrameLayout.

The solution is to use frameLayout.setVisibility(View.Visible) and frameLayout.setVisibility(View.Gone) on open and close events of sliding menu. It doesn't require an extra view to be added. And the black area is completely gone.

getSlidingMenu().setOnOpenListener(
    new OnOpenListener() {
        @Override
        public void onOpen() {
            frameLayout.setVisibility(View.GONE);
        }
    }
);

getSlidingMenu().setOnClosedListener(
    new OnClosedListener() {

        @Override
        public void onClosed() {
            frameLayout.setVisibility(View.VISIBLE);
        }
    }
);

Post a Comment for "Android Mapview With Sliding Menu Obscures Menu"