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

4 回答 4

2

我在这里尝试了所有方法,但没有一个效果很好。使用 GoogleOptions 将 zOrder 移动到顶部意味着基本的缩放控件隐藏在地图后面。
此链接的最后一个建议:https ://github.com/jfeinstein10/SlidingMenu/issues/168#issuecomment-17065660 (ckakei)为我修复了它。
诀窍是在布局中添加一个空的透明视图:

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

我在片段中夸大了这个视图。我用 SuppportMapFragment 替换了 view_map FrameLayout。

这是该课程的重要部分:

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();
}
于 2013-05-23T08:59:23.570 回答
2

解决方案是添加map:zOrderOnTop="true"到 XML。

有关更多信息,请参阅此链接

于 2013-04-24T03:50:54.370 回答
0

设置 MapView 背景透明 - android:background="#00000000"

于 2013-04-23T16:21:57.113 回答
0

我刚刚制作了地图复制视图,当滑动菜单打开或关闭时复制地图

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

滑动菜单打开监听器

    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);
    }
}
于 2013-05-09T05:49:02.867 回答