How to make rounded corners in DrawerLayout straight when switching to Theme.Material3

418 Views Asked by At

I've started the default Android project, "Navigation Drawer Activity".

enter image description here

I've changed the theme to:

<!-- <style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar">-->
    <style name="Theme.MyApplication" parent="Theme.Material3.DayNight.NoActionBar">

But then the Drawer has rounded corners:

enter image description here

How can I make these corners straight again?

2

There are 2 best solutions below

0
Gabriele Mariotti On BEST ANSWER

The corner size of the NavigationView is defined by the drawerLayoutCornerSize attribute in the style (default value with M3 theme = 16dp).

You can use in your layout:

<com.google.android.material.navigation.NavigationView
    android:id="@+id/nav_view"
    app:drawerLayoutCornerSize="0dp"

or you can define a custom style:

<style name="App.Material3.NavigationView" parent="Widget.Material3.NavigationView">
    <item name="drawerLayoutCornerSize">0dp</item>
</style>

and then apply it to the NavigationView

<com.google.android.material.navigation.NavigationView
    android:id="@+id/nav_view"
    style="@style/App.Material3.NavigationView"

enter image description here

0
Moklesur Rahman On

Just add this line in the com.google.android.material.navigation.NavigationView

app:drawerLayoutCornerSize="0dp"