[Extended Floating Action Button] elevation not respected in ExtendedFloatingActionButton
See original GitHub issueDescription: When using the ExtendedFloatingActionButton view, app:elevation is not respected like it is on the regular FloatingActionButton.
Expected behavior: This is what elevation 0 looks like on a regular FloatingActionButton with a transparent background:
vs elevation 4dp (notice the red sub-circle):
However, with app:elevation set to 0dp with the ExtendedFloatingActionButton, it looks the same as the second picture with 4dp elevation. I want the look of picture one, so I expect setting app:elevation to 0dp to give the same look.
Additionally, setting the text on the ExtendedFloatingActionButton gives inconsistent elevation results:
Source code: ExtendedFloatingActionButton xml:
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
style="@style/Theme.MyApp.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:elevation="0dp"
app:icon="@drawable/ic_location"
app:fabSize="mini"/>
Style xml:
<style name="ThemeOverlay.MyApp.QuickCaptureFloatingActionButton" parent="ShapeAppearance.MaterialComponents.SmallComponent">
<item name="cornerSize">100%</item>
<item name="cornerFamily">rounded</item>
</style>
<style name="Theme.MyApp.FloatingActionButton" parent="Widget.MaterialComponents.FloatingActionButton">
<item name="shapeAppearanceOverlay">@style/ThemeOverlay.MyApp.FloatingActionButton</item>
<item name="backgroundTint">#99000000</item>
<item name="color">#99000000</item>
<item name="android:hapticFeedbackEnabled">true</item>
</style>
Minimal sample app repro: efabbug.zip
Material Library version: 1.6.1, but also tested on 1.8.0-alpha01
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top GitHub Comments
Awesome! Going to close this bug since there is a workaround and there’s an existing bug (filed internally - b/132323220)
I did some more testing; I’m still able to repro this with transparent color with the regular FAB. Unfortunately I poked around and it looks like this is also an existing bug with transparent colours and material components that also use MaterialShapeDrawable.
At the crux of it, I’m not sure why the native shadows are still being drawn when elevation is set to 0, but one good workaround is to set the shadow attributes on the fab