thebluef0x
thebluef0x

Reputation: 23

Expand animation of a row in ListView

I have a ListView with restaurants. Each row has an expand button which lets you see the restaurant's menu. I'm trying to add a smooth expand animation. So far I've got something like this:

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

It is smooother than actually changing height with something like ValueAnimator (which is what I tried before).

My problem is that this animates only the row whose menu is expanding. I would like to animate also the visible rows below the row with expanding menu to achieve better visual effect. I tried to get them from the ListView with ListView.getChildAt() and apply similar TranslateAnimation on them but this doesn't work if the menu is too long. I believe this happens due to the View being recycled by my ListView so is there any workaround?

Upvotes: 1

Views: 65

Answers (1)

Eldhopj
Eldhopj

Reputation: 3609

Look at this Library, as per your explanation this will work perfectly https://github.com/h6ah4i/android-advancedrecyclerview

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

Upvotes: 1

Related Questions