Android support v23.1.0 update breaks NavigationView get/find header

With the design library v 23.1.0 the NavigationView works with a RecyclerView.
Also the Header is now a type of row.

It means that the header could not be immediately available in the view hierarchy.
It can cause issues if you are using methods like navigationView.findViewById(XXX) to get a view inside the header.

There is a bug in the Google Tracker.

EDIT 12/10/2015: Design library 23.1.1

The 23.1.1 introduces a new API for retrieving header views for NavigationView with getHeaderView()

BEFORE 23.1.1

workaround fot 23.1.0 can be to use a addOnLayoutChangeListener. Somenthing like:

navigationView.addOnLayoutChangeListener( new View.OnLayoutChangeListener()
    public void onLayoutChange( ... )
        navigationView.removeOnLayoutChangeListener( this );

        View view = navigationView.findViewById( ... );
} );

Another possible workaround are:

  • remove the app:headerLayout attribute from the xml, and then add the header programatically.

  • Inflate the headerView programmatically.

Use somenthing like this:

View headerLayout = navigationView.inflateHeaderView(R.layout.navigation_header);

It appears attaching the header view to the navigation drawer using xml is currently broken. The solution is to inflate and attach the view manually.

activity layout

    app:headerLayout="@layout/drawer_header" <!-- remove this line -->
    app:menu="@menu/drawer_items" />

Then in your code inflate and attach the header by doing the following.

NavigationView navigationView = (NavigationView) findViewById(;
View drawerHeader = navigationView.inflateHeaderView(R.layout.drawer_header);

TextView username = (TextView) drawerHeader.findViewById(;