Skip to content

Commit 13cdaba

Browse files
kendrickumstattddsn5ft
authored andcommitted
[Extended FAB][AppBar] Fix Extended FAB behavior demo to shrink and extend as expected.
Also: - Library fix to the AppBarLayout calculations for extended FAB versus FAB visibility. - Removed the M3 Expressive toolbar min heights in favor of actionBarSize. Resolves #4751 PiperOrigin-RevId: 764380548 (cherry picked from commit 1501d08)
1 parent bccfdfa commit 13cdaba

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

catalog/java/io/material/catalog/application/theme/res/values/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<!-- For the catalog we know that toolbars will always be on top of a "surface" color,
2020
so it's better for them to have no background, especially because it's common for
2121
toolbars to be nested in an AppBarLayout which has its own background handling. -->
22-
<style name="Widget.Catalog.Toolbar" parent="Widget.Material3.Toolbar.OnSurface" />
22+
<style name="Widget.Catalog.Toolbar" parent="Widget.Material3Expressive.Toolbar.OnSurface" />
2323

2424
<style name="Widget.Catalog.Toolbar.WithCloseButton">
2525
<item name="navigationContentDescription">@string/toolbar_navigation_close_description</item>

lib/java/com/google/android/material/appbar/AppBarLayout.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,17 +1012,22 @@ void onOffsetChanged(int offset) {
10121012
public final int getMinimumHeightForVisibleOverlappingContent() {
10131013
final int topInset = getTopInset();
10141014
final int minHeight = getMinimumHeight();
1015+
1016+
// If this layout has a min height, use it (doubled) or, if this doesn't clear the threshold,
1017+
// the min height.
10151018
if (minHeight != 0) {
1016-
// If this layout has a min height, use it (doubled)
1017-
return (minHeight * 2) + topInset;
1019+
int idealHeight = (minHeight * 2) + topInset;
1020+
return idealHeight < getHeight() ? idealHeight : minHeight + topInset;
10181021
}
10191022

1020-
// Otherwise, we'll use twice the min height of our last child
1023+
// Otherwise, we'll ideally use twice the min height of our last child or, if this doesn't
1024+
// clear the threshold, the min height of our last child.
10211025
final int childCount = getChildCount();
10221026
final int lastChildMinHeight =
10231027
childCount >= 1 ? getChildAt(childCount - 1).getMinimumHeight() : 0;
10241028
if (lastChildMinHeight != 0) {
1025-
return (lastChildMinHeight * 2) + topInset;
1029+
int idealHeight = (lastChildMinHeight * 2) + topInset;
1030+
return idealHeight < getHeight() ? idealHeight : lastChildMinHeight + topInset;
10261031
}
10271032

10281033
// If we reach here then we don't have a min height explicitly set. Instead we'll take a

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,18 @@
5252
<style name="Widget.Material3Expressive.Toolbar" parent="Widget.Material3.Toolbar">
5353
<item name="titleTextAppearance">@macro/m3_comp_app_bar_small_title_font</item>
5454
<item name="subtitleTextAppearance">@macro/m3_comp_app_bar_small_subtitle_font</item>
55-
<item name="android:minHeight">@dimen/m3_comp_app_bar_small_container_height</item>
5655
<item name="android:layout_marginEnd">4dp</item>
5756
</style>
5857

5958
<style name="Widget.Material3Expressive.Toolbar.OnSurface" parent="Widget.Material3.Toolbar.OnSurface">
6059
<item name="titleTextAppearance">@macro/m3_comp_app_bar_small_title_font</item>
6160
<item name="subtitleTextAppearance">@macro/m3_comp_app_bar_small_subtitle_font</item>
62-
<item name="android:minHeight">@dimen/m3_comp_app_bar_small_container_height</item>
6361
<item name="android:layout_marginEnd">4dp</item>
6462
</style>
6563

6664
<style name="Widget.Material3Expressive.Toolbar.Surface" parent="Widget.Material3.Toolbar.Surface">
6765
<item name="titleTextAppearance">@macro/m3_comp_app_bar_small_title_font</item>
6866
<item name="subtitleTextAppearance">@macro/m3_comp_app_bar_small_subtitle_font</item>
69-
<item name="android:minHeight">@dimen/m3_comp_app_bar_small_container_height</item>
7067
<item name="android:layout_marginEnd">4dp</item>
7168
</style>
7269

0 commit comments

Comments
 (0)