fab.setOnClickListener {
// Create an ObjectAnimator that scales the FAB from its current size to the size of your custom view or dialog.
val scaleAnimation = ObjectAnimator.ofPropertyValuesHolder(
fab,
PropertyValuesHolder.ofFloat(View.SCALE_X, 1.0f, 0.0f),
PropertyValuesHolder.ofFloat(View.SCALE_Y, 1.0f, 0.0f)
)
scaleAnimation.duration = 500 // set the duration of the animation in milliseconds
// Set a listener to be notified when the animation is complete.
scaleAnimation.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator?) {
// Once the animation is complete, remove the FAB from the view hierarchy.
fab.visibility = View.GONE
// Show your custom view or dialog on top of the FAB.
val customView = LayoutInflater.from(context).inflate(R.layout.custom_view, null)
val dialog = Dialog(context)
dialog.setContentView(customView)
dialog.show()
}
})
// Start the animation.
scaleAnimation.start()
}
1条答案
按热度按时间ljo96ir51#