user2527666 user2527666 - 1 year ago 240
Android Question

DrawerLayout.openDrawer does not work the first time

I am using a
in my activity.
As long as I use the swipe gesture to open it, it works fine.

However, when I want to open it through a button click by calling
, it does not work.

But, if I open it once using the swipe gesture, after that it works normally with button click.

Any idea how I could solve or work around this?

Answer Source

I had the same issue and I've just found out that for some reason the FrameLayout that represents the drawer have the visibility set to "gone", that probably goes to "visible" during the first slideGesture.

So, open your layout xml file, locate your FrameLayout that represents the drawer and simply erase the visibility setting. My opening tag is now as follows:


That worked for me.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download