Skip to content

Commit

Permalink
[FAB] Migrated "regular/default" sized styles to new shape system.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 452817382
  • Loading branch information
pekingme committed Jun 3, 2022
1 parent 1fe1618 commit 25482b1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
37 changes: 22 additions & 15 deletions docs/components/FloatingActionButton.md
Expand Up @@ -78,21 +78,28 @@ extendedFab.shrink()

### Sizing FABs

The `FloatingActionButton` can be sized either by using the discrete sizing
modes, a custom size, or for the large FAB by applying the desired style.

There are three `app:fabSize` modes:

* `normal` - the normal sized button, 56dp.
* `mini` - the small sized button, 40dp.
* `auto` (default) - the button size will change based on the window size. For
small sized windows (largest screen dimension < 470dp) this will select a
small sized button, and for larger sized windows it will select a normal
sized button.

Or, you can set a custom size via the `app:fabCustomSize` attribute. If set,
`app:fabSize` will be ignored, unless the custom size is cleared via the
`clearCustomSize` method.
The `FloatingActionButton` can be sized either by using `app:fabCustomSize` or
for the large/small FAB (M3 only) by applying the desired style. The
`app:fabSize` discrete size mode is deprecated in Material3 style. If the
`app:fabSize` is overridden in your FAB style, which inherits from one of these
styles:

* `Widget.Material3.FloatingActionButton(.Large).Primary`
* `Widget.Material3.FloatingActionButton(.Large).Secondary`
* `Widget.Material3.FloatingActionButton(.Large).Tertiary`
* `Widget.Material3.FloatingActionButton(.Large).Surface`

Please consider one of the following migration options:

* If `normal` size is used, set the parent style to
`Widget.Material3.FloatingActionButton.{Color}` and remove `app:fabSize`.
* If `mini` size is used, set the parent style to
`Widget.Material3.FloatingActionButton.Small.{Color}` and remove
`app:fabSize`.
* If FAB size changes in runtime by either setting `fabSize` or
`fabCustomSize`, and relative sized corners are desired, set
`shapeAppearanceOverlay` as
`@style/ShapeAppearanceOverlay.Material3.FloatingActionButton` in the style.

If you'd like to use the small FAB, apply one of these style attributes:

Expand Down
Expand Up @@ -25,7 +25,7 @@
<!-- Ripple color for the FAB. -->
<attr name="rippleColor"/>

<!-- Size for the FAB. If fabCustomSize is set, this will be ignored. -->
<!-- Size for the FAB. If fabCustomSize is set, this will be ignored. Deprecated in M3. -->
<attr name="fabSize">
<!-- A size which will change based on the window size. -->
<enum name="auto" value="-1"/>
Expand Down
Expand Up @@ -37,7 +37,6 @@
<dimen name="mtrl_extended_fab_end_padding">20dp</dimen>
<dimen name="mtrl_extended_fab_icon_size">24dp</dimen>
<dimen name="mtrl_extended_fab_icon_text_spacing">12dp</dimen>
<dimen name="mtrl_extended_fab_corner_radius">24dp</dimen>
<dimen name="mtrl_extended_fab_min_width">120dp</dimen>
<dimen name="mtrl_extended_fab_min_height">48dp</dimen>
<dimen name="mtrl_extended_fab_disabled_elevation">0dp</dimen>
Expand Down
Expand Up @@ -111,7 +111,8 @@
<item name="hoveredFocusedTranslationZ">@dimen/m3_fab_translation_z_hovered_focused</item>
<item name="pressedTranslationZ">@dimen/m3_fab_translation_z_pressed</item>
<item name="rippleColor">@color/m3_button_ripple_color_selector</item>
<item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.Material3.FloatingActionButton</item>
<item name="shapeAppearance">?attr/shapeAppearanceCornerLarge</item>
<item name="shapeAppearanceOverlay">@null</item>
<item name="tint">@color/m3_button_foreground_color_selector</item>
<!--Remove the motion spec and allow FloatingActionButtonImpl to create a theme-based animation-->
<item name="showMotionSpec">@null</item>
Expand Down Expand Up @@ -242,6 +243,12 @@
</style>

<!-- Overlays -->

<!--
Deprecation:
Shape appearances in Material3 FAB styles are migrated to new shape theme attributes.
This percentage-based corners overlay is only used for existing usage where FAB size changes at runtime.
-->
<style name="ShapeAppearanceOverlay.Material3.FloatingActionButton" parent="">
<item name="cornerSize">@dimen/m3_fab_corner_size</item>
</style>
Expand Down

0 comments on commit 25482b1

Please sign in to comment.