[英]How to make rounded corners in DrawerLayout straight when switching to Theme.Material3
I've started the default Android project, "Navigation Drawer Activity".我已经启动了默认的 Android 项目“Navigation Drawer Activity”。
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:但是抽屉有圆角:
How can I make these corners straight again?我怎样才能使这些角再次变直?
The corner size of the NavigationView
is defined by the drawerLayoutCornerSize
attribute in the style (default value with M3 theme = 16dp
). NavigationView
的角尺寸由样式中的drawerLayoutCornerSize
属性定义( M3主题的默认值 = 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
然后将它应用到
NavigationView
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
style="@style/App.Material3.NavigationView"
Just add this line in the com.google.android.material.navigation.NavigationView
只需在
com.google.android.material.navigation.NavigationView
添加这一行
app:drawerLayoutCornerSize="0dp"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.