问题
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