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 50
50
android : elevation =" @dimen/design_appbar_elevation"
51
51
app : subtitle =" Surface Elevated"
52
52
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" />
53
61
</LinearLayout >
54
62
</ScrollView >
Original file line number Diff line number Diff line change @@ -596,6 +596,22 @@ layout configuration.
596
596
597
597
<details >
598
598
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
+
599
615
<summary ><h3 >Applying scrolling behavior to app bars</h3 ></summary >
600
616
601
617
When scrolling up, the collapsing top app bar transforms into a regular top app
Original file line number Diff line number Diff line change 22
22
<public name =" collapsingToolbarLayoutMediumSize" type =" attr" />
23
23
<public name =" collapsingToolbarLayoutLargeSize" type =" attr" />
24
24
<public name =" toolbarSurfaceStyle" type =" attr" />
25
+ <public name =" toolbarNavigationButtonCircleColor" type =" attr" />
25
26
<public name =" layout_scrollInterpolator" type =" attr" />
26
27
<public name =" layout_scrollEffect" type =" attr" />
27
28
<public name =" behavior_overlapTop" type =" attr" />
64
65
<public name =" Widget.Material3.Toolbar" type =" style" />
65
66
<public name =" Widget.Material3.Toolbar.Surface" type =" style" />
66
67
<public name =" Widget.Material3.Toolbar.OnSurface" type =" style" />
68
+ <public name =" Widget.Material3.Toolbar.Button.Navigation.Circle" type =" style" />
67
69
<public name =" Widget.Material3.ActionBar.Solid" type =" style" />
68
70
<public name =" Widget.Material3.Light.ActionBar.Solid" type =" style" />
69
71
<public name =" Widget.Material3.ActionMode" type =" style" />
70
72
<public name =" ThemeOverlay.MaterialComponents.Toolbar.Primary" type =" style" />
71
73
<public name =" ThemeOverlay.MaterialComponents.Toolbar.Surface" type =" style" />
72
74
<public name =" ThemeOverlay.Material3.Toolbar.Surface" type =" style" />
75
+ <public name =" ThemeOverlay.Material3.Toolbar.CircleNavigationButton" type =" style" />
73
76
<public name =" TextAppearance.Design.CollapsingToolbar.Expanded" type =" style" />
74
77
<public name =" TextAppearance.Material3.ActionBar.Subtitle" type =" style" />
75
78
<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 37
37
<!-- Style to use for Surface Toolbars in this theme. -->
38
38
<attr name =" toolbarSurfaceStyle" format =" reference" />
39
39
40
+ <!-- Color of the circle when using ThemeOverlay.Material3.Toolbar.CircleNavigationButton. -->
41
+ <attr name =" toolbarNavigationButtonCircleColor" format =" color" />
42
+
40
43
<declare-styleable name =" AppBarLayout" >
41
44
<!-- Deprecated. Elevation is now controlled via a state list animator. -->
42
45
<attr name =" elevation" />
Original file line number Diff line number Diff line change 33
33
<dimen name =" m3_appbar_scrim_height_trigger_medium" >112dp</dimen >
34
34
<dimen name =" m3_appbar_scrim_height_trigger_large" >112dp</dimen >
35
35
<dimen name =" m3_toolbar_text_size_title" >20dp</dimen >
36
+ <dimen name =" m3_toolbar_button_circle_size" >40dp</dimen >
36
37
</resources >
Original file line number Diff line number Diff line change 154
154
<item name =" colorControlNormal" >@macro/m3_comp_app_bar_trailing_icon_color</item >
155
155
</style >
156
156
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
+
157
166
<!-- Style for a M3 ActionBar (inherited from AppCompat due to different
158
167
desired configuration compared to MaterialComponents ActionBars). -->
159
168
<style name =" Base.Widget.Material3.ActionBar.Solid" parent =" Widget.AppCompat.ActionBar.Solid" >
You can’t perform that action at this time.
0 commit comments