DrawerLayout not working with Android 4.4 & Surfac

2019-02-18 19:56发布

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条回答
我想做一个坏孩纸
2楼-- · 2019-02-18 20:37

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();
    }
查看更多
登录 后发表回答