I have a pretty standard navigation menu. When I use a static layout in the header as shown below, it works fine.
<android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_height="match_parent" android:layout_width="wrap_content" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/nav_header" app:menu="@menu/drawer_view"/>
But I want to have a dynamic header, so I can change it when the user is logged in, etc. So I tried using a snippet instead of nav_header.xml
<android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_height="match_parent" android:layout_width="wrap_content" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/fragment_header" app:menu="@menu/drawer_view"/>
Can I use a fragment in headerLayout, so I can process all my logic in a java fragment file. Or what is the right solution to solve this problem.
source share