Android MapView With Sliding Menu Obscures Menu
Asked Answered
S

3

5

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 page. There is a black view covering the sliding menu that is the exact size of the map. This is an example with the map height set at 100dp to outline what I mean.

View Issue

If I touch that view it will go away. How would I get rid of it or make it transparent? I've tried the requestTransparentRegion() trick. No dice there.

Siloa answered 12/2, 2013 at 20:32 Comment(5)
Whats this iOS search bar??? That just looks wrong...Cope
Just following the comps.Siloa
Just look at these one: grokkingandroid.com/…Cope
The search isn't the issue here. The black view on the slideout menu is. It's obviously attached the maps, but I don't know why.Siloa
I know it's not related to the question, that's why the comment section is there.Cope
S
13

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
 */
public class TransparentSupportMapFragment extends SupportMapFragment {

    public TransparentSupportMapFragment() {}

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

        View layout = super.onCreateView(inflater, view, savedInstance);
        FrameLayout frameLayout = new FrameLayout(getActivity());
        frameLayout.setBackgroundColor(
           getResources().getColor(android.R.color.transparent));
        ((ViewGroup) layout).addView(frameLayout,
            new ViewGroup.LayoutParams(
               LayoutParams.MATCH_PARENT, 
               LayoutParams.MATCH_PARENT
            )
        );
        return layout;
    }

}
Siloa answered 15/2, 2013 at 15:10 Comment(0)
P
0

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);
        }
    }
);
Photogene answered 2/3, 2013 at 9:19 Comment(0)
P
0

TransparentSupportMapFragment solved the problem for android 2.3.7 Thank you!

Perfumer answered 12/7, 2013 at 4:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.