Skip to content

Commit 699302a

Browse files
afohrmanhunterstich
authored andcommitted
[FloatingToolbar] Integrated tokens for floating toolbar and add new styles for the horizontal, vertical and vibrant style variations.
PiperOrigin-RevId: 696175995
1 parent 5bcda8a commit 699302a

File tree

5 files changed

+87
-21
lines changed

5 files changed

+87
-21
lines changed

catalog/java/io/material/catalog/floatingtoolbar/res/layout/cat_floating_toolbar_fragment.xml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
xmlns:android="http://schemas.android.com/apk/res/android"
1818
xmlns:app="http://schemas.android.com/apk/res-auto"
1919
android:layout_width="match_parent"
20-
android:layout_height="match_parent">
20+
android:layout_height="match_parent"
21+
android:padding="8dp">
2122

2223
<androidx.core.widget.NestedScrollView
2324
android:layout_width="match_parent"
@@ -74,12 +75,10 @@
7475

7576
<com.google.android.material.floatingtoolbar.FloatingToolbarLayout
7677
android:id="@+id/floating_toolbar_left"
77-
style="@style/Widget.Material3.FloatingToolbar"
78+
style="@style/Widget.Material3.FloatingToolbar.Vertical"
7879
android:layout_width="wrap_content"
7980
android:layout_height="wrap_content"
80-
android:layout_margin="36dp"
8181
android:layout_gravity="left|center"
82-
android:paddingVertical="8dp"
8382
android:visibility="gone">
8483
<LinearLayout
8584
android:id="@+id/floating_toolbar_child_left"
@@ -93,12 +92,9 @@
9392

9493
<com.google.android.material.floatingtoolbar.FloatingToolbarLayout
9594
android:id="@+id/floating_toolbar_right"
96-
style="@style/Widget.Material3.FloatingToolbar"
95+
style="@style/Widget.Material3.FloatingToolbar.Vertical"
9796
android:layout_width="wrap_content"
9897
android:layout_height="wrap_content"
99-
android:layout_margin="36dp"
100-
android:layout_gravity="right|center"
101-
android:paddingVertical="8dp"
10298
android:visibility="gone">
10399
<LinearLayout
104100
android:id="@+id/floating_toolbar_child_right"
@@ -112,12 +108,9 @@
112108

113109
<com.google.android.material.floatingtoolbar.FloatingToolbarLayout
114110
android:id="@+id/floating_toolbar_bottom"
115-
style="@style/Widget.Material3.FloatingToolbar"
111+
style="@style/Widget.Material3.FloatingToolbar.Horizontal"
116112
android:layout_width="wrap_content"
117-
android:layout_height="wrap_content"
118-
android:layout_margin="36dp"
119-
android:layout_gravity="bottom|center"
120-
android:paddingHorizontal="8dp">
113+
android:layout_height="wrap_content">
121114
<LinearLayout
122115
android:id="@+id/floating_toolbar_child_bottom"
123116
android:layout_width="match_parent"

lib/java/com/google/android/material/floatingtoolbar/FloatingToolbarLayout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* {@link android.view.ViewGroup}.
4848
*/
4949
public class FloatingToolbarLayout extends FrameLayout implements AttachedBehavior {
50-
private static final int DEF_STYLE_RES = R.style.Widget_Material3_FloatingToolbar;
50+
private static final int DEF_STYLE_RES = R.style.Widget_Material3_FloatingToolbar_Horizontal;
5151
@Nullable private Behavior behavior;
5252

5353
public FloatingToolbarLayout(@NonNull Context context) {

lib/java/com/google/android/material/floatingtoolbar/res-public/values/public.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@
1616
-->
1717
<resources>
1818
<public name="floatingToolbarStyle" type="attr"/>
19-
<public name="Widget.Material3.FloatingToolbar" type="style"/>
19+
<public name="Widget.Material3.FloatingToolbar.Horizontal" type="style"/>
20+
<public name="Widget.Material3.FloatingToolbar.Horizontal.Vibrant" type="style"/>
21+
<public name="Widget.Material3.FloatingToolbar.Vertical" type="style"/>
22+
<public name="Widget.Material3.FloatingToolbar.Vertical.Vibrant" type="style"/>
2023
</resources>

lib/java/com/google/android/material/floatingtoolbar/res/values/styles.xml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,49 @@
1515
~ limitations under the License.
1616
-->
1717
<resources>
18-
19-
<style name="Widget.Material3.FloatingToolbar" parent="">
18+
<!-- Base style for Floating Toolbar. Do not use; use one of the horizontal or vertical variants,
19+
instead. -->
20+
<style name="Base.Widget.Material3.FloatingToolbar" parent="">
2021
<item name="enforceMaterialTheme">true</item>
21-
<item name="android:minHeight">@dimen/m3_floatingtoolbar_min_height</item>
22-
<item name="android:minWidth">@dimen/m3_floatingtoolbar_min_width</item>
23-
<item name="backgroundTint">?attr/colorSurfaceContainer</item>
24-
<item name="shapeAppearance">@style/ShapeAppearance.Material3.Corner.Full</item>
22+
<item name="android:minHeight">@dimen/m3_comp_toolbar_floating_container_height</item>
23+
<item name="android:minWidth">@dimen/m3_comp_toolbar_floating_container_height</item>
24+
<item name="backgroundTint">@macro/m3_comp_toolbar_floating_standard_container_color</item>
25+
<item name="shapeAppearance">@style/ShapeAppearance.M3.Comp.Toolbar.Floating.Container.Shape</item>
26+
<item name="android:layout_margin">@dimen/m3_comp_toolbar_floating_container_external_padding</item>
27+
</style>
28+
29+
<!-- Style for Horizontal Floating Toolbar.
30+
Note that layout_* attributes break when set via a default style. Always set this style
31+
explicitly on the layout to ensure that layout_* attributes are set properly. -->
32+
<style name="Widget.Material3.FloatingToolbar.Horizontal" parent="Base.Widget.Material3.FloatingToolbar">
33+
<item name="android:paddingStart">@dimen/m3_comp_toolbar_floating_container_leading_space</item>
34+
<item name="android:paddingEnd">@dimen/m3_comp_toolbar_floating_container_trailing_space</item>
35+
<item name="android:layout_gravity">bottom|center</item>
36+
</style>
37+
38+
<!-- Style for Vibrant color variation of the Horizontal Floating Toolbar.
39+
Note that layout_* attributes break when set via a default style. Always set this style
40+
explicitly on the layout to ensure that layout_* attributes are set properly. -->
41+
<style name="Widget.Material3.FloatingToolbar.Horizontal.Vibrant">
42+
<item name="backgroundTint">@macro/m3_comp_toolbar_floating_vibrant_container_color</item>
43+
</style>
44+
45+
<!-- Style for Vibrant color variation of the Vertical Floating Toolbar. Defaults to the right
46+
side; override android:layout_gravity to position the toolbar on the left side. Note that
47+
layout_* attributes break when set via a default style. Always set this style explicitly on
48+
the layout to ensure that layout_* attributes are set properly. -->
49+
<style name="Widget.Material3.FloatingToolbar.Vertical" parent="Base.Widget.Material3.FloatingToolbar">
50+
<item name="android:paddingTop">@dimen/m3_comp_toolbar_floating_container_leading_space</item>
51+
<item name="android:paddingBottom">@dimen/m3_comp_toolbar_floating_container_trailing_space</item>
52+
<item name="android:layout_gravity">right|center</item>
53+
</style>
54+
55+
<!-- Style for Vibrant color variation of the Vertical Floating Toolbar. Defaults to the right
56+
side; override android:layout_gravity to position the toolbar on the left side. Note that
57+
layout_* attributes break when set via a default style. Always set this style explicitly on
58+
the layout to ensure that layout_* attributes are set properly. -->
59+
<style name="Widget.Material3.FloatingToolbar.Vertical.Vibrant">
60+
<item name="backgroundTint">@macro/m3_comp_toolbar_floating_vibrant_container_color</item>
2561
</style>
2662

2763
</resources>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2024 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+
<!-- AUTOGENERATED FILE. DO NOT MODIFY. -->
18+
<!-- Version: 10.0.1 -->
19+
20+
<resources>
21+
22+
<!-- Generated from token set (md.comp.toolbar.floating) in context (platform=android, audience=3p). -->
23+
<!-- Group: Color -->
24+
<macro name="m3_comp_toolbar_floating_standard_container_color">?attr/colorSurfaceContainer</macro>
25+
<macro name="m3_comp_toolbar_floating_vibrant_container_color">?attr/colorPrimaryContainer</macro>
26+
<!-- Group: Size -->
27+
<dimen name="m3_comp_toolbar_floating_container_height">64dp</dimen>
28+
<dimen name="m3_comp_toolbar_floating_container_leading_space">8dp</dimen>
29+
<dimen name="m3_comp_toolbar_floating_container_trailing_space">8dp</dimen>
30+
<dimen name="m3_comp_toolbar_floating_container_external_padding">16dp</dimen>
31+
<!-- Group: Shape -->
32+
<style name="ShapeAppearance.M3.Comp.Toolbar.Floating.Container.Shape" parent="ShapeAppearance.M3.Sys.Shape.Corner.Full"/>
33+
34+
</resources>

0 commit comments

Comments
 (0)