【问题标题】:How to animate view from bottom to top in android如何在android中从下到上动画视图
【发布时间】:2021-10-30 13:40:53
【问题描述】:

我有 listView,我在其中从底部添加项目。 我想为添加的项目设置动画,列表视图的其余部分应该向上滑动。 动画效果应该是从下到上。 我试过翻译动画,但它只滑动添加的项目。 谢谢

【问题讨论】:

标签: android android-layout


【解决方案1】:
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);
}

【讨论】:

    【解决方案2】:

    看看这个 LIB 它可能对你有帮助

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

    【讨论】:

      【解决方案3】:

      尝试将listView背景设置为白色

      【讨论】:

      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 2016-12-11
      • 1970-01-01
      • 1970-01-01
      • 2019-10-17
      • 2011-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多