How to remove black cover on top of sliding menu?

徘徊边缘 提交于 2019-12-07 18:16:28

问题


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.

=> 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"/> 

回答1:


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

For more info please refer to this link.




回答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();
}



回答3:


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




回答4:


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);
    }
}


来源:https://stackoverflow.com/questions/16173075/how-to-remove-black-cover-on-top-of-sliding-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!