Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DrawerLayout.openDrawer does not work the first time

Tags:

I am using a android.support.v4.widget.DrawerLayout 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 drawer.openDrawer(Gravity.LEFT), 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?

like image 331
user2527666 Avatar asked Aug 06 '13 19:08

user2527666


2 Answers

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:

<FrameLayout     android:layout_width="305dp"     android:layout_height="match_parent"     android:layout_gravity="start"> 

That worked for me.

Cheers

like image 80
Eduardo Lino Avatar answered Oct 30 '22 22:10

Eduardo Lino


In my case the visibility on 'NavigationView' was set to gone in the layout. Changing it to visible solved the issue

like image 39
CodesmithX Avatar answered Oct 30 '22 20:10

CodesmithX