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?
Asked
Active
Viewed 7,286 times
12

Gabriele Mariotti
- 320,139
- 94
- 887
- 841

Manoj Perumarath
- 9,337
- 8
- 56
- 77
2 Answers
18
The biggest difference is the use of a MaterialShapeDrawable
as background implementing some Material features, such as shaping and elevation overlays for Dark Themes.

Gabriele Mariotti
- 320,139
- 94
- 887
- 841
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:

MDikkii
- 273
- 1
- 10