Material Toolbar
MaterialToolbar is a Toolbar that implements certain Material features, such as elevation overlays for Dark Themes and centered titles.
Regarding the Dark Theme elevation overlays, it's important to note that the Material component also provides elevation overlay support, and operates under the assumption that the child Toolbar does not have a background. While a
MaterialToolbar with a transparent background can be used within an AppBarLayout, in terms of elevation overlays its main value comes into play with the standalone Toolbar case, when using the Widget.MaterialComponents.Toolbar.Surface style with elevation.
To get started with the MaterialToolbar component, use
com.google.android.material.appbar.MaterialToolbar in your layout XML instead of
androidx.appcompat.widget.Toolbar or Toolbar. E.g.,:
<com.google.android.material.appbar.MaterialToolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"/>