Hello,
Welcome to our Microsoft Q&A platform!
a header for which I want it to horizontally stretch to fit
To make the header fit the the navigationView. Please set the android:layout_width
of the header layout to android:layout_width match_parent instead. Here is the sample code, you could refer to it.
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
...
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer"/>
layout/nav_header_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
...>
...
</LinearLayout>
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.