Animate view sliding out of another view, pushing views below out of the way

后端 未结 7 1557
野趣味
野趣味 2020-12-22 21:27

I have a list of buttons. When I press a button, a View should slide in a downwards motion out of the button, like this:

Start:

7条回答
  •  -上瘾入骨i
    2020-12-22 22:08

    I would do it like that. First the layout for the whole collapsible panel component: (pseudo xml)

    RelativeLayout (id=panel, clip)
        LinearLayout (id=content, alignParentBottom=true)
        LinearLayout (id=handle, above=content)
    

    This should ensure that the content is always below the handle.

    Then when you need to collapse:

    • Animate the top margin of content from 0 to -content.height
    • Animate the height of the panel from current to current-content.height

提交回复
热议问题