Description: An article describe an issue encountered when the working on android project. A click event not triggered due to the layout update.
For reason, i’m working on a android project.
I encountered an issue which the click event not triggered.
The layout xml is similar as below, i tried so hard to make the click event work, not no success.
After a half day search and trail and error, the issue solved by moving the NavigationView tag to lower location in xml. [Answer in stackoverflow]
Wrong example
<?xml version="1.0" encoding="utf-8"?>
<layout>
<DrawerLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
<RelativeLayout>
.
.
.
</RelativeLayout>
</DrawerLayout>
</layout>
Correct example
<?xml version="1.0" encoding="utf-8"?>
<layout>
<DrawerLayout>
<RelativeLayout>
.
.
.
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</DrawerLayout>
</layout>
The reason of the issue, according to the answer from stackoverflow, it is because of NavigationView is block or covered by the RelativeLayout