如何在安卓中实现从底部到顶部的视图动画

6

我有一个listView,我从底部添加项目。 我想要动画效果,同时其余的列表视图应该向上滑动。 动画效果应该是从底部到顶部。 我尝试了translate animation,但它只会滑动添加的项目。 谢谢


请查看此问题:https://dev59.com/71LTa4cB1Zd3GeqPeeaJ - Harpreet
3个回答

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

0

0
尝试将listView的背景设置为白色。

1
你的回答可以通过提供更多支持信息来改进。请编辑以添加进一步的细节,例如引用或文档,以便他人可以确认你的答案是正确的。您可以在帮助中心中找到有关如何编写良好答案的更多信息。 - Community

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接