[ExtendedFloatingActionButton] background clip animation does not work
See original GitHub issueDescription: When custom background is set to clip drawable, or any containing like below
<clip
android:clipOrientation="horizontal"
android:gravity="start">
<shape android:shape="rectangle">
<corners
android:bottomLeftRadius="?attr/progressingButtonCornerRadius"
android:bottomRightRadius="?attr/progressingButtonCornerRadius"
android:topLeftRadius="?attr/progressingButtonCornerRadius"
android:topRightRadius="?attr/progressingButtonCornerRadius" />
<solid android:color="?attr/progressingButtonBackground" />
</shape>
</clip>
cliping does not work; setting the same for normal button does work.
Expected behavior:
With ExtendedFloatingActionButton
With simple Button
Source code: background drawable
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners
android:bottomLeftRadius="25dp"
android:bottomRightRadius="25dp"
android:topLeftRadius="25dp"
android:topRightRadius="25dp" />
<solid android:color="@color/white" />
<stroke android:width="4dp" android:color="#D81B60"/>
</shape>
</item>
<item android:id="@+id/clipItem">
<clip
android:clipOrientation="horizontal"
android:gravity="start">
<shape android:shape="rectangle">
<corners
android:bottomLeftRadius="25dp"
android:bottomRightRadius="25dp"
android:topLeftRadius="25dp"
android:topRightRadius="25dp" />
<solid android:color="#D81B60" />
</shape>
</clip>
</item>
</layer-list>
background replacement
val drawable = prepareDrawable(R.drawable.extended_progressive_bg, R.style.ProgressingButton_Cancel) as LayerDrawable
clipDrawable = drawable.findDrawableByLayerId(R.id.clipItem)
ext_btn.background = drawable
ext_btn
is either Button
or com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
. Please notice that Button
!= com.google.android.material.button.MaterialButton
; (when I replaced Button
with it, it also did not work)
animation
val animator = TimeAnimator()
val maxTime = 10 * 1000
animator.setTimeListener { _, totalTime, _ ->
clipDrawable.level = (totalTime.toDouble() / maxTime * 10000).toInt()
f (totalTime > maxTime) {
animator.cancel()
}
}
animator.start()
Android API version: 30
Material Library version: 1.4.0
Device: Pixel 4
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
FloatingActionButton with text instead of image - Stack Overflow
Thanks to all. Here is easy workaround which I found for this question. Works correctly for Android 4+, for Android 5+ is added...
Read more >[ExtendedFloatingActionButton] shrink not work with ... - GitHub
My workaround is to wrap the MotionLayout into another Layout where I put the ExtendedFAB and then use a TransitionListener in the MotionLayout ......
Read more >Expandable Floating Action Button - Android Studio Tutorial
Your browser can 't play this video. ... Watch my video about to learn how to create Custom Animation resource files: https://youtu.be/ ...
Read more >[1P8] Observations to the new design - 1Password Community
New and Edit buttons are odd. Why not use an extended floating action button? Bigger and easier to press, and more in line...
Read more >Buttons: floating action button - Material Design
The extend animation extends the FAB to show the text and the icon. ... Regular FABs are FABs that are not expanded and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think you need to get the clip drawable “after” you set the background.
I didn’t know the exact reason but it seems after you set the view background the returned clip drawable changes.
Yeah… Thank you. For all with the same problem, below works:
I tried with stacking backgrounds to have the ripple effect from the original one, but it did not work at the first time, I did not go deeper; I suppose it is needed to add ripple by yourself.