3

In my application i have a sliding menu which has been developed by jfeinstein10. It's working fine in my application ;)

I have a Fragment which is host of MapView. This fragment like my other fragments extended from Fragment class. Just in this Fragment, there is black cover/layer on top of menu contents when I open sliding menu. There is no black cover when I open menu in other fragments. Also, the thing that I found is height of box is exactly as same height as fragment.

Have you seen this problem before? any comments or suggestion would be appreciated.

enter image description here

=> Update

Based on what Selei suggested I set background to transparent. However, regardless of what color I'm assigning (transparent or other colors) it's still visible and black :( This is my code:

<?xml version="1.0" encoding="utf-8"?>

<com.google.android.gms.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    android:id="@+id/mapView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true"
    map:uiCompass="true"
    android:background="#00000000"/> 
Hartok
  • 2,147
  • 20
  • 37
Hesam
  • 52,260
  • 74
  • 224
  • 365
  • Thanks Mars, Actually I didn't put my code because it works fine. I don't think it's because of code, all functionalitys are correct. I guess maybe someone have faced this problem before. I guess it should because of MapView. but i'm not sure :( – Hesam Apr 23 '13 at 15:27

4 Answers4

2

The solution was adding map:zOrderOnTop="true" to XML.

For more info please refer to this link.

Hesam
  • 52,260
  • 74
  • 224
  • 365
2

I tried all the methods here but none of them worked great. Using the GoogleOptions to move the zOrder to the top meant the basic zoom controls were hidden behind the map.
The last suggestion at this link: https://github.com/jfeinstein10/SlidingMenu/issues/168#issuecomment-17065660 (ckakei) fixed it for me.
The trick is to add an empty, transparent view to the layout:

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

<FrameLayout
    android:id="@+id/view_map"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
</FrameLayout>
<View
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent" />

I'm inflating this view then in a Fragment. I replace the view_map FrameLayout with the SuppportMapFragment.

This is the important part from that class:

private GoogleMap googleMap;
private SupportMapFragment mapFragment;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    return inflater.inflate(R.layout.view_map_layout, container,
            false);

}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    FragmentManager fm = getChildFragmentManager();
    if (mapFragment == null) {
        mapFragment = SupportMapFragment.newInstance();
    }
    if (savedInstanceState == null) {
        mapFragment.setRetainInstance(true);
    } else {
        googleMap = mapFragment.getMap();
    }
    fm.beginTransaction().replace(R.id.view_map, mapFragment).commit();
}
karol
  • 368
  • 2
  • 8
  • This works, thanks! But I had to comment out setRetainInstance(true) as I got a nested fragments error. I only use this for Build.VERSION.SDK_INT < 11 – alice_silver_man Feb 12 '15 at 05:52
0

set the MapView background transparent - android:background="#00000000"

Laurentiu
  • 47
  • 1
  • 9
  • Thanks Selei, but it's still visible. I have added code of UI to question. Please check it. Thanks again ;) – Hesam Apr 24 '13 at 02:30
0

I just made map copy view which copy the map when the sliding menu open or close

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private void showMapCopy(boolean show) {

    View map = findViewById(R.id.map);
    View mapCopy = findViewById(R.id.map_copy);

    if (show) {
        map.setDrawingCacheEnabled(true);
        Bitmap bitmap = map.getDrawingCache();
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
            mapCopy.setBackgroundDrawable(new BitmapDrawable(getResources(), bitmap));
        else
            mapCopy.setBackground(new BitmapDrawable(getResources(), bitmap));
        mapCopy.setVisibility(View.VISIBLE);
    } else {
        map.setDrawingCacheEnabled(false);
        mapCopy.setVisibility(View.GONE);
    }
}

Sliding Menu Open Listener

    mMenu.setOnClosedListener(new OnClosedListener() {
        @Override
        public void onClosed() {
            showMapCopy(false);
        }
    });

OnOptionItemSelected

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case R.id.abs__home:
        case android.R.id.home:
                showMapCopy(true);
                mMenu.toggle();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
The Finest Artist
  • 3,150
  • 29
  • 34