Ultimate Guide to Material 3 Docked Toolbar in Android XML (2025 Tutorial + Examples)

Ultimate Guide to Material 3 Docked Toolbar in Android: Tutorial & Examples for 2025 🚀

Overview 📖

Material 3 Docked Toolbars display page-specific actions, typically at the bottom of the screen, with optional hide-on-scroll behavior and overflow menus for limited space. This guide covers their implementation, accessibility, and theming for 2025. 🛠️

Overview of Material 3 Docked Toolbar

Design and API Documentation 🔗

Using Docked Toolbars 🤖

Add the Material Components for Android library dependency to use Material 3 Docked Toolbars. See the Get Started guide. Use DockedToolbarLayout with OverflowLinearLayout for dynamic action layouts. Use a Theme.Material3.* theme for proper styling. 🛠️

Making Docked Toolbars Accessible ♿

Set android:contentDescription on actions for screen readers like TalkBack. Use accessibilityTraversalBefore/After for focus order. Disable hide-on-scroll for TalkBack with padding adjustments. See the Android accessibility guide. 🗣️

Behavior and Configuration 🎬

Enable hide-on-scroll with HideViewOnScrollBehavior. Use OverflowLinearLayout for overflow menus. Handle clicks on actions or overflow items. Example:

      
val backButton = findViewById
      
    

Docked Toolbar Anatomy 🌟

Material 3 Docked Toolbars consist of a container and content, typically buttons or icons, with optional overflow menu support for limited space. 📋

Docked Toolbar anatomy diagram
  • Container: DockedToolbarLayout, holds content.
  • Content: Actions in OverflowLinearLayout, e.g., icon buttons. 🖱️

Docked Toolbar Example 🔲

Docked Toolbars provide flexible, page-specific actions with hide-on-scroll and overflow capabilities. 📋

Docked Toolbar example

Docked Toolbar Example 💻

API and source code:

The following example shows a docked toolbar with three icon buttons and overflow menu support.

      

    
        
    
    
        
            
                
            
                
        
    

      
      
    
      
val backButton = findViewById
      
    

Anatomy and Key Properties 📏

A docked toolbar includes a container and action content. 📋

Docked Toolbar anatomy diagram
  • Container: DockedToolbarLayout, typically bottom-aligned.
  • Content: Icon buttons or custom views in OverflowLinearLayout. 🖱️

Attributes 📋

Element Attribute Related method(s) Default value
Container app:backgroundTint N/A ?attr/colorSurfaceContainer
app:shapeAppearance N/A 0% rounded
app:paddingBottomSystemWindowInsets N/A Unset (auto-applied if bottom-aligned)
Behavior app:layout_behavior N/A null

Styles 🎨

  • Default style: Widget.Material3.DockedToolbar
  • Vibrant style: Widget.Material3.DockedToolbar.Vibrant
  • Default style theme attribute: ?attr/dockedToolbarStyle

See the full list of styles and attrs. 🔗

Theming Docked Toolbars 🖌️

Material Theming customizes docked toolbar colors and typography. 🎨

Themed Docked Toolbar with custom colors

Theming Example 💻

Theming example for docked toolbars:

      

      
      
    

Specific styles for docked toolbars without affecting other components:

      





      
      
    

FAQ ❓

What is a Material 3 Docked Toolbar? 🤔

A bottom-aligned toolbar for page-specific actions with overflow support. ✅


How does it differ from Bottom App Bar? 🔢

More flexible than BottomAppBar, with custom layouts and overflow menus. 📋


When to use a Docked Toolbar? 🖋️

Use for page-specific actions needing hide-on-scroll or overflow menus. 🛠️


How to make it accessible? ♿

Set contentDescription on actions; manage TalkBack focus order. 🗣️


Can I customize its appearance? 🎨

Yes, theme colors and typography via res/values/styles.xml. 🖌️


How to add the Material 3 library? 📦

Include the Material Components for Android library. See the Get Started guide. 🛠️


Are there updates for 2025? 🗓️

This guide reflects 2025 Material 3 standards for docked toolbars. 🚀

Comments

Popular posts from this blog

Creating Beautiful Card UI in Flutter

Master Web Development with Web School Offline

Jetpack Compose - Card View