I've seen other answers and they all apply to actionbars not toolbars and they require creating new shapes.
Is there a simple way to do this using the styles.xml
?
I've seen other answers and they all apply to actionbars not toolbars and they require creating new shapes.
Is there a simple way to do this using the styles.xml
?
Create a drawable resource (e.g curvedToolbar.XML):
<?xml version="1.0" encoding ="utf-8"?>
<shape xmls:android="http://schemas.android.com/apk/red/android"
android:shape="rectangle">
<corners android:radius= "20dp"/>
</shape>
Add it to your toolbar like this:
<androidx.appcompat.widget.Toolbar
......
android:background= "@drawable/curvedToolbar"
/>
It isn't what you are looking for because it is not with a xml.
Currently (
1.2.0-beta01
and1.3.0-alpha01
) theToolbar
orMaterialToolbar
don't support ashapeAppearance
style as other components in thestyles.xml
.But you can use in any case the
ShapeAppearanceModel
provided by the Material Components Library.In your layout:
Then just apply the
ShapeAppearanceModel
with rounded corners: