The Android Developer Challenge is back! Submit your idea before December 2.

MaterialToolbar

public class MaterialToolbar
extends Toolbar

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ androidx.appcompat.widget.Toolbar
         ↳ com.google.android.material.appbar.MaterialToolbar


MaterialToolbar is a Toolbar that implements certain Material features, such as elevation overlays for Dark Themes.

Regarding the Dark Theme elevation overlays, it's important to note that the Material AppBarLayout 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"/>
 

Summary

Inherited constants

From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

MaterialToolbar(Context context)
MaterialToolbar(Context context, AttributeSet attrs)
MaterialToolbar(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

void setElevation(float elevation)

Protected methods

void onAttachedToWindow()

Inherited methods

From class androidx.appcompat.widget.Toolbar
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.view.ViewParent
From interface android.view.ViewManager
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public constructors

MaterialToolbar

MaterialToolbar (Context context)

Parameters
context Context

MaterialToolbar

MaterialToolbar (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

MaterialToolbar

MaterialToolbar (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

setElevation

void setElevation (float elevation)

Parameters
elevation float

Protected methods

onAttachedToWindow

void onAttachedToWindow ()