简体   繁体   中英

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

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);
}

尝试将 listView 背景设置为白色

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM