DrawerLayout not working with Android 4.4 & SurfaceView

蹲街弑〆低调 提交于 2019-12-30 10:34:50

问题


Today I had one of those "android" moments again, which left me absolutely clueless.

I have an app which consists of a DrawerLayout, which includes a RelativeLayout as container for a SurfaceView (surfaceViewContainer) and a second ViewGroup (subclass of RelativeLayout) as navigation.

When the app starts, in onCreate I inflate the layout and add a SurfaceView to the surfaceViewContainer.

On a Samsung S2 with 4.1.2 and a S3 with 4.3 everything works fine, I can see the SurfaceView drawn and I can open and close the drawer, by swipe gesture or home button. Then I tested on Android 4.4 with a Nexus 5 and a Nexus 10, on both devices the drawer will not appear. Even pushing the home button won't do a thing.

Even stranger : I can open the Drawer before adding the SurfaceView, when I do so I can interact with the Drawer even after adding the SurfaceView, even on Android 4.4, so open/close works then.

So my question : Anybody experienced something like this before or has some advice or knows what might have changed from Android 4.3 to 4.4?!

ps: I used DrawerLayout successfully in other apps already, just not with SurfaceView, so I assume the problem lies there.

Thanks


回答1:


Have you tried using implementing onDrawerSlide on the drawerListener of the drawerLayour like this

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


来源:https://stackoverflow.com/questions/20976149/drawerlayout-not-working-with-android-4-4-surfaceview

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