File tree Expand file tree Collapse file tree 8 files changed +73
-0
lines changed
catalog/java/io/material/catalog/topappbar/res/layout
lib/java/com/google/android/material/appbar Expand file tree Collapse file tree 8 files changed +73
-0
lines changed Original file line number Diff line number Diff line change 5050 android : elevation =" @dimen/design_appbar_elevation"
5151 app : subtitle =" Surface Elevated"
5252 app : title =" Toolbar" />
53+
54+ <com .google.android.material.appbar.MaterialToolbar
55+ android : layout_width =" match_parent"
56+ android : layout_height =" wrap_content"
57+ android : layout_marginTop =" 32dp"
58+ android : theme =" @style/ThemeOverlay.Material3.Toolbar.CircleNavigationButton"
59+ app : subtitle =" Circle Navigation Button"
60+ app : title =" Toolbar" />
5361 </LinearLayout >
5462</ScrollView >
Original file line number Diff line number Diff line change @@ -596,6 +596,22 @@ layout configuration.
596596
597597<details >
598598
599+ <summary ><h3 >Adding a circle to the navigation button</h3 ></summary >
600+
601+ If you would like to add a circle background to the navigation icon, set the
602+ ` android:theme="@style/ThemeOverlay.Material3.Toolbar.CircleNavigationButton" `
603+ theme overlay on your ` Toolbar ` or ` MaterialToolbar ` .
604+
605+ By default, the theme overlay above uses ` ?attr/colorSurfaceContainer ` for the
606+ circle color. This can be customized by extending the theme overlay and setting
607+ the ` toolbarNavigationButtonCircleColor ` attribute.
608+
609+ <img src =" assets/topappbar/topappbar_circle_nav_button.png " alt =" Top app bar with circle navigation button background. " width =" 600 " />
610+
611+ </details >
612+
613+ <details >
614+
599615<summary ><h3 >Applying scrolling behavior to app bars</h3 ></summary >
600616
601617When scrolling up, the collapsing top app bar transforms into a regular top app
Original file line number Diff line number Diff line change 2222 <public name =" collapsingToolbarLayoutMediumSize" type =" attr" />
2323 <public name =" collapsingToolbarLayoutLargeSize" type =" attr" />
2424 <public name =" toolbarSurfaceStyle" type =" attr" />
25+ <public name =" toolbarNavigationButtonCircleColor" type =" attr" />
2526 <public name =" layout_scrollInterpolator" type =" attr" />
2627 <public name =" layout_scrollEffect" type =" attr" />
2728 <public name =" behavior_overlapTop" type =" attr" />
6465 <public name =" Widget.Material3.Toolbar" type =" style" />
6566 <public name =" Widget.Material3.Toolbar.Surface" type =" style" />
6667 <public name =" Widget.Material3.Toolbar.OnSurface" type =" style" />
68+ <public name =" Widget.Material3.Toolbar.Button.Navigation.Circle" type =" style" />
6769 <public name =" Widget.Material3.ActionBar.Solid" type =" style" />
6870 <public name =" Widget.Material3.Light.ActionBar.Solid" type =" style" />
6971 <public name =" Widget.Material3.ActionMode" type =" style" />
7072 <public name =" ThemeOverlay.MaterialComponents.Toolbar.Primary" type =" style" />
7173 <public name =" ThemeOverlay.MaterialComponents.Toolbar.Surface" type =" style" />
7274 <public name =" ThemeOverlay.Material3.Toolbar.Surface" type =" style" />
75+ <public name =" ThemeOverlay.Material3.Toolbar.CircleNavigationButton" type =" style" />
7376 <public name =" TextAppearance.Design.CollapsingToolbar.Expanded" type =" style" />
7477 <public name =" TextAppearance.Material3.ActionBar.Subtitle" type =" style" />
7578 <public name =" TextAppearance.Material3.ActionBar.Title" type =" style" />
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <!--
3+ ~ Copyright (C) 2025 The Android Open Source Project
4+ ~
5+ ~ Licensed under the Apache License, Version 2.0 (the "License");
6+ ~ you may not use this file except in compliance with the License.
7+ ~ You may obtain a copy of the License at
8+ ~
9+ ~ http://www.apache.org/licenses/LICENSE-2.0
10+ ~
11+ ~ Unless required by applicable law or agreed to in writing, software
12+ ~ distributed under the License is distributed on an "AS IS" BASIS,
13+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ ~ See the License for the specific language governing permissions and
15+ ~ limitations under the License.
16+ -->
17+ <layer-list xmlns : android =" http://schemas.android.com/apk/res/android" >
18+
19+ <!-- Circle. -->
20+ <item
21+ android : width =" @dimen/m3_toolbar_button_circle_size"
22+ android : height =" @dimen/m3_toolbar_button_circle_size"
23+ android : gravity =" center" >
24+ <shape android : shape =" oval" >
25+ <solid android : color =" ?attr/toolbarNavigationButtonCircleColor" />
26+ </shape >
27+ </item >
28+
29+ <!-- Ripple, which should be on top of the Circle but below the Icon. -->
30+ <item
31+ android : drawable =" ?attr/controlBackground"
32+ android : gravity =" center" />
33+ </layer-list >
Original file line number Diff line number Diff line change 3737 <!-- Style to use for Surface Toolbars in this theme. -->
3838 <attr name =" toolbarSurfaceStyle" format =" reference" />
3939
40+ <!-- Color of the circle when using ThemeOverlay.Material3.Toolbar.CircleNavigationButton. -->
41+ <attr name =" toolbarNavigationButtonCircleColor" format =" color" />
42+
4043 <declare-styleable name =" AppBarLayout" >
4144 <!-- Deprecated. Elevation is now controlled via a state list animator. -->
4245 <attr name =" elevation" />
Original file line number Diff line number Diff line change 3333 <dimen name =" m3_appbar_scrim_height_trigger_medium" >112dp</dimen >
3434 <dimen name =" m3_appbar_scrim_height_trigger_large" >112dp</dimen >
3535 <dimen name =" m3_toolbar_text_size_title" >20dp</dimen >
36+ <dimen name =" m3_toolbar_button_circle_size" >40dp</dimen >
3637</resources >
Original file line number Diff line number Diff line change 154154 <item name =" colorControlNormal" >@macro/m3_comp_app_bar_trailing_icon_color</item >
155155 </style >
156156
157+ <style name =" ThemeOverlay.Material3.Toolbar.CircleNavigationButton" parent =" " >
158+ <item name =" toolbarNavigationButtonCircleColor" >?attr/colorSurfaceContainer</item >
159+ <item name =" toolbarNavigationButtonStyle" >@style/Widget.Material3.Toolbar.Button.Navigation.Circle</item >
160+ </style >
161+
162+ <style name =" Widget.Material3.Toolbar.Button.Navigation.Circle" parent =" Widget.AppCompat.Toolbar.Button.Navigation" >
163+ <item name =" android:background" >@drawable/m3_toolbar_navigation_circle_background</item >
164+ </style >
165+
157166 <!-- Style for a M3 ActionBar (inherited from AppCompat due to different
158167 desired configuration compared to MaterialComponents ActionBars). -->
159168 <style name =" Base.Widget.Material3.ActionBar.Solid" parent =" Widget.AppCompat.ActionBar.Solid" >
You can’t perform that action at this time.
0 commit comments