When to use MaterialToolbar and androidx Toolbar and the difference between both?
Asked Answered
S

2

12

When i switched to AndroidX i found that the Toolbar has moved to androidx.appcompat.widget.Toolbar also there is a new MaterialToolbar introduced as com.google.android.material.appbar.MaterialToolbar What is the difference between these two and when to use these?

Slicer answered 28/11, 2019 at 6:32 Comment(0)
M
19

The biggest difference is the use of a MaterialShapeDrawable as background implementing some Material features, such as shaping and elevation overlays for Dark Themes.

Michaella answered 28/11, 2019 at 8:0 Comment(0)
H
4

You can find the answer in the docs of MaterialToolbar: https://developer.android.com/reference/com/google/android/material/appbar/MaterialToolbar

Simply MaterialToolbar extends androidx.appcompat.widget.Toolbar and let it behave as MaterialComponent. The main feature seems to be elevation. You can read through the implementation here:

https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/appbar/MaterialToolbar.java

Hydrology answered 28/11, 2019 at 7:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.