question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FloatingActionButton] App crashes because of shapeAppearance on FAB

See original GitHub issue

Description: Here is the Demo app https://github.com/ashraf-patel/MaterialComponentsDemo, as described in this link to the gif you can reproduce the crash.

Expected behavior: It should not crash.

Source code:

Here is the problem, making cornerSizeTopRight and cornerSizeBottomLeft to 30dp is causing the crash. link to the Gif

<style name="ShapeAppearance.Sunflower.FAB" parent="ShapeAppearance.MaterialComponents">
        <item name="cornerFamily">rounded</item>
        <item name="cornerSizeTopLeft">0dp</item>
        <item name="cornerSizeTopRight">30dp</item>
        <item name="cornerSizeBottomRight">0dp</item>
        <item name="cornerSizeBottomLeft">30dp</item>
</style>

Below code works link to the gif

<style name="ShapeAppearance.Sunflower.FAB" parent="ShapeAppearance.MaterialComponents">
        <item name="cornerFamily">rounded</item>
        <item name="cornerSizeTopLeft">0dp</item>
        <item name="cornerSizeTopRight">0dp</item>
        <item name="cornerSizeBottomRight">0dp</item>
        <item name="cornerSizeBottomLeft">0dp</item>
</style>

https://github.com/ashraf-patel/MaterialComponentsDemo is the Demo app.

Android API version: OS: 8.0

Material Library version: 1.1.0-beta01

Device: Device: Pixel 2 XL Emulator

StackOverflow: https://stackoverflow.com/questions/58225921/shapeappearance-in-material-component-floatingactionbutton-causes-a-crash

Issue in original repository: https://github.com/android/sunflower/issues/519

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cketchamcommented, Dec 12, 2019

Resolved by 3c3ac61

1reaction
ymariancommented, Oct 8, 2019

My bad the corner can be more than 50% since the other one on the same side is 0.

@gabrielemariotti It repros in 26.

I’ll have to debug this tomorrow setting app:shapeAppearanceOverlay=“@null” seems to help, which doesn’t make sense to me since the ShapeAppearance in the example is setting the more specific cornerSizes. The default fab overlay only sets app:cornerSize to 50% the shape appearance should ignore the overlay in this case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

shapeAppearance in Material Component ...
Using shapeAppearance attribute causes a crash. This is the FAB in XML <com.google.android.material.floatingactionbutton.FloatingActionButton ...
Read more >
[FloatingActionButton] View is crashing the preview [130710290]
I cannot upload the app since it is IP of the company, but something as simple as just the FAB inside a Coordinator...
Read more >
Theming Floating Action Buttons in Android with Example
Floating Action Button (FAB) in Android with Example ... Otherwise, the app will crash immediately as soon as we launch the application.
Read more >
Buttons: floating action button - Material Design
A floating action button (FAB) performs the primary, or most common, action on a screen. It appears in front of all screen content,...
Read more >
Add a Floating Action Button - Android Developers
A floating action button (FAB) is a circular button that triggers the primary action in your app's UI. This page shows you how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found