如何创建浮动操作按钮转换为单张材料

时间:2015-10-13 02:33:01

标签: android material-design

我试图查看设计库中是否存在任何内置动画,以创建浮动动作按钮转换为单一材质表,如材料设计图像中所示

https://material-design.storage.googleapis.com/publish/material_v_4/material_ext_publish/0B8v7jImPsDi-TjBicTdvQjg4M1E/components-buttons-fab-transition_card_02.webm

2 个答案:

答案 0 :(得分:2)

你试过https://github.com/gowong/material-sheet-fab,它是Android武器库的一部分吗?

答案 1 :(得分:0)

使用材料成分中的MaterialContainerTransform

 private fun toggleFabMenu() {
        val views = listOf<View>(fab, menuView).sortedBy { !it.isVisible }

        val shareMenuTransform = MaterialContainerTransform().apply {
            startView = views.first()
            endView = views.last()           
            scrimColor = Color.TRANSPARENT
            duration = 500
                      
        }
        TransitionManager.beginDelayedTransition(root, shareMenuTransform)
        views.first().isVisible = false
        views.last().isVisible = true
    }

enter image description here

有关更多详细信息,请参阅文档:https://material.io/develop/android/theming/motion