Home > front end >  How to make rounded corners in DrawerLayout straight when switching to Theme.Material3
How to make rounded corners in DrawerLayout straight when switching to Theme.Material3

Time:11-22

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?

CodePudding user response:

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

app:drawerLayoutCornerSize="0dp"

CodePudding user response:

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

  • Related