DrawerLayout does not work with Android 4.4 and SurfaceView

Today I again had one of those “android” moments that left me completely ignorant.

I have an application consisting of DrawerLayout that includes a RelativeLayout as a container for a SurfaceView (surfaceViewContainer) and a second ViewGroup (a subclass of RelativeLayout) as a navigation.

When the application starts, in onCreate I will inflate the layout and add a SurfaceView to the surface of the ViewContainer.

On Samsung S2 with 4.1.2 and S3 with 4.3 everything works fine, I see that SurfaceView is drawn, and I can open and close the drawer with a swipe gesture or the home button. Then I tested on Android 4.4 with Nexus 5 and Nexus 10, the box will not appear on both devices. Even pressing the home button will do nothing.

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

So my question is: has anyone experienced something like this before or has some tips or knows what could change from Android 4.3 to 4.4 ?!

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

thank

+3
source share
1 answer

Have you tried using the onDrawerSlide implementation on drawerListener drawerLayour, like this

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

Source: https://habr.com/ru/post/1530818/


All Articles