E/OpenGLRenderer: resultIndex is -1, the polygon must be invalid!
A/OpenGLRenderer: Error: Spot pair overflow!!! used 38, total 22
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 11996 (hwuiTask1)
Using shapeAppearance attribute causes a crash.
This is the FAB in XML
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
style="@style/Widget.MaterialComponents.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:onClick="@{() -> callback.add(viewModel.plant)}"
android:tint="@android:color/white"
app:shapeAppearance="@style/ShapeAppearance.Sunflower.FAB" <--
app:isGone="@{viewModel.isPlanted}"
app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom|end"
app:srcCompat="@drawable/ic_plus" />
Below is the style for shapeAppearance,
<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>
This solves the crash.
<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>
I need to know the reason behind it and how to solve it while using the same corner style.
Use the app:shapeAppearanceOverlay
attribute:
<com.google.android.material.floatingactionbutton.FloatingActionButton
app:shapeAppearanceOverlay="@style/CustomShapeOVerlay"
/>
And in the style (without defining the parent
)
<style name="CustomShapeOVerlay" parent="">
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With