[Android动画-靠近对象

问题描述 投票:2回答:1

我一直在尝试跟随scenario制作动画。基本上我想从一些ImageViews垂直排列并分布在整个屏幕上,并且在执行某些操作(按下按钮等)后,它们应移动closer。重要的是要提到ImageViews的数量可以根据情况而变化(在图片中并不总是3个)因此,一般的解决方案将是更好的选择。

我的第一种方法是列出Recyclerview中的图像,并spread使用自定义ItemDecoration的图像,如下所示:

class CustomItemDecorator(private val spaceHeight: Int) : RecyclerView.ItemDecoration() {
    override fun getItemOffsets(
        outRect: Rect,
        view: View,
        parent: RecyclerView,
        state: RecyclerView.State
    ) {
        with(outRect) {
            if (parent.getChildAdapterPosition(view) == 0) {
                top = spaceHeight
            }
            bottom = spaceHeight
        }
    }
}

通过移除ItemDecorator(myRecyclerView.removeItemDecoration(my_decorator))我能够带上图像[[closer。尽管此功能适用于任意数量的图像,以改善用户体验,但我想对此过渡进行[动画]。我尝试将一些更复杂的动画应用于RecyclerView,但到目前为止没有任何效果。我很乐意提出任何建议:-)

我一直在尝试以下场景的动画。基本上,我想从一些垂直排列的ImageView开始,并在执行某些操作后散布在屏幕上(button -...
android android-recyclerview android-animation objectanimator item-decoration
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.