If you set app:headerLayout="@layout/drawer_header
then you don’t have to inflate the view again. You can just use .bind
instead of .inflate
.
You can get the already inflated header view and bind it like this:
View headerView = binding.navigationView.getHeaderView(0);
DrawerHeaderBinding headerBinding = DrawerHeaderBinding.bind(headerView);