user1537457
user1537457

Reputation: 109

How to animate view from bottom to top in android

I have listView in which i am adding item from bottom. I want to animate added item and rest of list view should slide up. Animation effect should be from bottom to top. I have tried translate animation but it slides only added item. Thanks

Upvotes: 6

Views: 9882

Answers (3)

Don Benito
Don Benito

Reputation: 55

Try to set the listView background to white

Upvotes: 0

pvllnspk
pvllnspk

Reputation: 5767

public static void slideToBottom(View view){
    TranslateAnimation animate = new TranslateAnimation(0,0,0,view.getHeight());
    animate.setDuration(500);
    animate.setFillAfter(true);
    view.startAnimation(animate);
    view.setVisibility(View.GONE);
}

public static void slideToTop(View view){
    TranslateAnimation animate = new TranslateAnimation(0,0,view.getHeight(),0);
    animate.setDuration(500);
    animate.setFillAfter(true);
    view.startAnimation(animate);
    view.setVisibility(View.VISIBLE);
}

Upvotes: 19

MilapTank
MilapTank

Reputation: 10076

see this LIB it may helps you

http://nhaarman.github.io/ListViewAnimations/?ref=app

Upvotes: 0

Related Questions