navigation drawer google maps v2 , map blocking drawer

与世无争的帅哥 提交于 2019-11-29 02:51:21

问题


I have this problem when opening drawer on gingerbread and behind is google map v2. Map that should be on screen behind gets on top of everything.

Now I could bypass this by hiding map when drawer opens and show it when closes but I'm looking for more elegant solution if someone came up with any?


回答1:


There is a bug with google maps api v2 and black space. Maybe you have got similar problem. For solutions look here: https://github.com/jfeinstein10/SlidingMenu/issues/228 and here: https://github.com/jfeinstein10/SlidingMenu/issues/168

As far as I remember solutions are one of this:

  • extending Google Maps and make it to redraw every view more often
  • set map's z index on top param to true
  • put transparent overlay over Google Maps view



回答2:


Just wrap SupportMapFragment with FrameLayout and put transparent View above like this:

<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <!-- Map fragment -->
        <fragment
            android:id="@+id/map"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            class="com.google.android.gms.maps.SupportMapFragment" />
        <!-- Transparent view -->
        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

Tested with Android 4.0.4 - works fine for me




回答3:


I have got the same problem here on ICS 4.0.4. The solutions mentioned in jfeinstein10's github post seems not working for me. But I have found a workaround, even it is not the best.

When creating DrawerToggle object I override this event

@Override
public void onDrawerSlide(View drawerView, float slideOffset)
{
     super.onDrawerSlide(drawerView, slideOffset);
     mDrawerLayout.bringChildToFront(drawerView);
     mDrawerLayout.requestLayout();
     mDrawerLayout.setScrimColor(Color.TRANSPARENT);

}

bringChildToFront and requestLayout method should overcome the drawer rendering problem while setScrimColor will get rid of the shadow. Too bad that I haven't found a workaround to render the shadow correctly as well. Hope this helps.




回答4:


You should override the onDrawerSlide function and move the drawer to front

 Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
    DrawerLayout  Drawer = (DrawerLayout) findViewById(R.id.DrawerLayout);
                    mDrawerToggle = new ActionBarDrawerToggle(this, Drawer, toolbar, R.string.openDrawer, R.string.closeDrawer) {

                        @Override
                        public void onDrawerSlide(View drawerView, float slideOffset)
                        {
                            super.onDrawerSlide(drawerView, slideOffset);
                            Drawer.bringChildToFront(drawerView);
                            Drawer.requestLayout();
                            Drawer.setScrimColor(Color.TRANSPARENT);

                        }
                    };


来源:https://stackoverflow.com/questions/17733723/navigation-drawer-google-maps-v2-map-blocking-drawer

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