简体   繁体   English

从上到下的大图像翻译动画Android

[英]Translation animation of large image from top to bottom Android

I'm trying to develop a splash screen with a large image scrolling (Animating) from top to bottom. 我正在尝试使用从顶部到底部的大图像滚动(动画)来开发启动屏幕。 I dont think using ScrollView would be good since I dont want the user to scroll the image. 我不认为使用ScrollView会很好,因为我不希望用户滚动图像。

This is what I would like to achieve: 这是我要实现的目标: 在此处输入图片说明

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

</set>

create this animation as slidedown.xml in an anim folder in the project and use the code below in the java file that has the view.You may change the values of "android:fromYdelta" according to your need. 在项目的anim文件夹中将此动画创建为slidedown.xml,并在具有视图的java文件中使用以下代码。您可以根据需要更改“ android:fromYdelta”的值。

myImageView.startAnimation(slidedown);

For example if your imageview is 250 px use : 例如,如果您的imageview为250 px,请使用:

ObjectAnimator.ofFloat(myImageView, "translationY", 250);

And in xml set on your imageview : 并在您的imageview上设置的xml中:

android:translationY="-250"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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