Open GitUser4732 opened 7 years ago
Any solution yet?
what i did:
fab:menu_fab_hide_animation="@anim/fade_out"
fab:menu_fab_show_animation="@anim/fade_in"
is not perfect, but at least doesn't affect the groups layout. It stays in place.
For anyone still using this lib or one of its forks, these extensions I made worked for me, it uses the icon inside the primary FAB as the pivot point.
In some cases you might need to wrap the code inside the function in a post{ }
block.
fun FloatingActionMenu.show() {
if (visibility != View.VISIBLE) {
val pivotX = menuIconView.pivotX + menuIconView.x
val pivotY = menuIconView.pivotY + menuIconView.y
val anim = ScaleAnimation(
0f, 1f, 0f, 1f, Animation.ABSOLUTE, pivotX,
Animation.ABSOLUTE, pivotY
)
anim.duration = 200
anim.interpolator = LinearInterpolator()
startAnimation(anim)
}
visibility = View.VISIBLE
close(false)
}
fun FloatingActionMenu.hide() {
if (visibility == View.VISIBLE) {
val pivotX = menuIconView.pivotX + menuIconView.x
val pivotY = menuIconView.pivotY + menuIconView.y
val anim = ScaleAnimation(
1f, 0f, 1f, 0f, Animation.ABSOLUTE, pivotX,
Animation.ABSOLUTE, pivotY
)
anim.duration = 200
anim.interpolator = LinearInterpolator()
startAnimation(anim)
}
visibility = View.INVISIBLE
close(false)
}
When hiding and showing menu button the animation is not centered on the button but the entire view group's(Button ,menu buttons and labels) bounds. How can I have these animations look similar to the normal FAB and animate to the buttons center and not the entire viewgroup?
Thanks