将动画从屏幕顶部移动到中间

5

我正在翻译两个重叠图像的平移动画,两个图像都应该从屏幕顶部平移到中间。请分享一些此类程序的示例。

帮助总是受欢迎的...谢谢!

2个回答

5

anim.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="0" android:toYDelta="50%p" android:duration="1000"/>
</set>

在Java文件中...
Animation anim = AnimationUtils.loadAnimation(activity, R.anim.anim);
anim.setInterpolator((new AccelerateDecelerateInterpolator()));
anim.setFillAfter(true);
ImageView.setAnimation(anim);

非常感谢,但是我们如何使两个图像连续地启用和禁用,您能分享一下功能吗? - user709589
我没有相关代码,但我可以向您解释。您可以根据需要设置ImageView的可见性。 - Niranj Patel

3
要将屏幕从顶部动画到中间,应该像这样:
anmation.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
  <translate
      android:fromYDelta="-50%p"
      android:toYDelta="0%p"
      android:duration="2000" />
</set>


要使用此动画

Animation bottomUp = AnimationUtils.loadAnimation(this,
            R.anim.animation);
    tv_logo.startAnimation(bottomUp);

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