Layer Layout accepts touch event instead of navigation bar items

My android project contains 2 navigation boxes. One on the right side, the other on the left. It opens by pressing a button:

if (mDrawerLayout.isDrawerOpen(mRightDrawerView))
    mDrawerLayout.closeDrawer(mRightDrawerView);
mDrawerLayout.openDrawer(mLeftDrawerView);

Both boxes have custom layouts defined with:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<include
    android:id="@+id/left_drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    layout="@layout/menu_panel" />

<include
    android:id="@+id/right_drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="end"
    layout="@layout/search_panel" />

</android.support.v4.widget.DrawerLayout> 

The problem is this: when I open the box and try to capture its click event, (there are buttons and text images in the box layout) the box closes instead of responding to click events.

I also used:

mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
mDrawerLayout.requestDisallowInterceptTouchEvent(true);

I do not want the drawer to close on a sensory event inside it.

I also tried changing the "clickable" attribute in the box layout. But to no avail.

Any help is greatly appreciated. Thanks

+4
1

, , , , , .

"true" , . .

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<include
    android:id="@+id/left_drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:clickable="true"
    layout="@layout/menu_panel" />

<include
    android:id="@+id/right_drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="end"
    android:clickable="true"
    layout="@layout/search_panel" />

</android.support.v4.widget.DrawerLayout> 
+1

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


All Articles