【问题标题】:Android View animation to top parentAndroid View 动画到顶级父级
【发布时间】:2016-11-18 09:55:24
【问题描述】:

我的目标是将当前视图从其当前位置(中心)动画到其父级的顶部边框。那可能吗?我已经尝试过下一个代码,但问题是我的视图在动画后消失了:

Animation bottomUp = AnimationUtils.loadAnimation(context, R.anim.bottom_up);
popup.startAnimation(bottomUp);

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:fromYDelta="100%"
        android:toYDelta="0%"
        android:fillAfter="true"
        android:duration="500"/>
</set>

【问题讨论】:

    标签: android animation android-animation translate


    【解决方案1】:

    ViewPropertyAnimator 可以在 Java 中轻松完成

    popup.animate().translationY(0).setDuration(500); // 0 is top of Y axis
    

    动画总是从当前位置开始。

    查看ViewPropertyAnimator 文档以了解未来的动画,它非常易于使用并且可以为您节省大量代码。

    【讨论】:

      猜你喜欢
      • 2011-04-17
      • 1970-01-01
      • 2016-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-06
      • 1970-01-01
      • 2019-05-27
      相关资源
      最近更新 更多