Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation drawer - Disable click through on items behind the drawer

Is there any way to make sure that the navigation drawer stays on top of the content in the fragment?

I created a small test application with dummy data. 10 fragments with a corresponding numbered button and textview. The issue is with the fact that the fragment elements seem to have higher priority than the navigation drawer.

enter image description here

As seen in the screenshot, once I attempt to open up the "0 fragment" it instead opts to register the click on the button behind the navigation drawer. Pressing any other content item works fine, but this is as long as there are no other interactable items beneath them. What can I do to have the navigation drawer properly stay on top of the content behind it?

like image 916
user1240989 Avatar asked Jul 06 '13 00:07

user1240989


People also ask

How do I customize my navigation drawer?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. Step 3 − Add the following code to res/layout/nav_header_main.

How does navigation drawer work?

The navigation drawer slides in from the left and contains the navigation destinations for the app. The user can view the navigation drawer when the user swipes a finger from the left edge of the activity. They can also find it from the home activity by tapping the app icon in the action bar.

Which piece of code is used to close the navigation drawer?

Use closeDrawer() method to close the drawer and start your other activity on the listener of drawer.


2 Answers

Set android:clickable="true" tag on sliding pane layout.

like image 159
Gennadiy Ryabkin Avatar answered Sep 20 '22 15:09

Gennadiy Ryabkin


The problem seem not because of click focus,

Visit https://developer.android.com/training/implementing-navigation/nav-drawer.html#DrawerLayout

The main content view (the FrameLayout above) must be the first child in the DrawerLayout because the XML order implies z-ordering and the drawer must be on top of the content.

like image 31
theinlin kyaw Avatar answered Sep 19 '22 15:09

theinlin kyaw