【问题标题】:Expand animation of a row in ListView展开 ListView 中一行的动画
【发布时间】:2018-09-11 20:24:05
【问题描述】:

我有一个ListView 与餐馆。每行都有一个展开按钮,可让您查看餐厅的菜单。我正在尝试添加平滑的展开动画。到目前为止,我有这样的东西:

TranslateAnimation expandAnimation = new TranslateAnimation(0f, 0f, -targetHeight, 0f)
expandAnimation.setDuration(300)
menuLayout.startAnimation(expandAnimation)

这比使用ValueAnimator(这是我之前尝试过的)等实际改变高度要顺畅。

我的问题是这只会为菜单正在扩展的行设置动画。我还想用扩展菜单对行下方的可见行进行动画处理,以实现更好的视觉效果。我试图从ListViewListView.getChildAt() 获取它们,并在它们上应用类似的TranslateAnimation,但如果菜单太长,这将不起作用。我相信这是因为View 被我的ListView 回收,所以有什么解决方法吗?

【问题讨论】:

    标签: java android listview android-studio


    【解决方案1】:

    看看这个库,根据你的解释,这将完美地工作 https://github.com/h6ah4i/android-advancedrecyclerview

    dependencies {
        implementation ('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.11.0@aar'){
            transitive=true
        }
    }
    

    【讨论】:

    • 谢谢。这看起来正是我想要的!
    • 快乐的编码伙伴?
    猜你喜欢
    • 2012-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-18
    • 2015-08-24
    • 2011-04-20
    • 1970-01-01
    相关资源
    最近更新 更多