kotlin 创建一个可扩展的晶圆厂自定义对话框

68bkxrlz  于 2023-03-24  发布在  Kotlin
关注(0)|答案(1)|浏览(228)

我想创建一个晶圆厂自定义对话框动画和过渡,我尝试了许多代码和库,但结果并不像我预期的那样,所以我想基本上点击晶圆厂和加班它的形状成自定义视图或自定义对话框如下所示,谢谢

  • Youtube网址

Youtube Link Here

ljo96ir5

ljo96ir51#

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()
}

相关问题