To customize the appearance of the drawer, create a custom style in your styles.xml that inherits from Widget.MaterialDrawerStyle. You can override specific attributes such as background colors, text colors, icon colors, and divider colors.
After defining your custom drawer style, you must also define a header style (inheriting from a suitable parent) and then link both styles to your application's main theme using the materialDrawerStyle and materialDrawerHeaderStyle attributes.
<!-- 1. Define a custom drawer style -->
<style name="Widget.MaterialDrawerStyleCustom" parent="Widget.MaterialDrawerStyle">
<item name="materialDrawerInsetForeground">#4000</item>
<item name="materialDrawerBackground">?colorSurface</item>
<item name="materialDrawerPrimaryText">@color/color_drawer_item_text</item>
<item name="materialDrawerPrimaryIcon">@color/color_drawer_item_text</item>
<item name="materialDrawerSecondaryText">@color/color_drawer_item_text</item>
<item name="materialDrawerSecondaryIcon">@color/color_drawer_item_text</item>
<item name="materialDrawerDividerColor">?colorOutline</item>
<item name="materialDrawerSelectedBackgroundColor">?colorSecondaryContainer</item>
</style>
<!-- 2. Define a custom header style -->
<style name="Widget.MaterialDrawerHeaderStyleCustom" parent="">
<item name="materialDrawerCompactStyle">true</item>
<item name="materialDrawerHeaderSelectionText">?colorOnSurface</item>
<item name="materialDrawerHeaderSelectionSubtext">?colorOnSurface</item>
</style>
<!-- 3. Apply styles to your app theme -->
<style name="SampleApp" parent="Theme.Material3.Light.NoActionBar">
<item name="materialDrawerStyle">@style/Widget.MaterialDrawerStyleCustom</item>
<item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStyleCustom</item>
</style>