简体   繁体   English

Android Java使图像向下移动

[英]Android Java make a image move down

How can i make a image just scroll down a straight line by it self? 我怎样才能使图像自行向下滚动一条直线?

Like 喜欢

The Image starts up here and then it will just smoothly scroll down till it hits the bottom and stop 图像从此处开始,然后平稳地向下滚动直到到达底部并停止

Please look at this: http://tinypic.com/r/1z17iv9/7 请查看以下内容: http : //tinypic.com/r/1z17iv9/7

i think you should take a look about TranslateAnimation on the doc , refer this , 我认为您应该在文档上看一下TranslateAnimation ,请参考一下

And this is some examples of it : Tutorials 这是它的一些示例: 教程

You should save this TopDownAnim.xml in the anim folder inside resources. 您应该将此TopDownAnim.xml保存在资源内的anim文件夹中。

<translate android:interpolator="@android:anim/accelerate_interpolator" 
    android:fromXDelta="0" android:toXDelta="0" android:zAdjustment="top" 
    android:fromYDelta="0%" android:toYDelta="100%" android:duration="1000"/>

And in the code you can use something like 在代码中,您可以使用类似

TranslateAnimation tdAnim = AnimationUtils.loadAnimation(this, 
        R.anim.TopDownAnim);

view.startAnimation(tdAnim);

Your question is a bit vague, but I think what you're looking for is a ScrollView. 您的问题有点含糊,但我认为您正在寻找的是ScrollView。 Try referring to this documentation . 尝试参考本文档 What you want to do is to put the ImageView inside this ScrollView. 您要做的是将ImageView放入此ScrollView中。

EDIT Ah, I see. 编辑啊,我知道了。 I apologize for misunderstanding what you were asking about. 对于您的询问有误会,我深表歉意。 Perhaps you should consider animating the ImageView with some basic view animations. 也许您应该考虑使用一些基本的视图动画为ImageView设置动画。 Try looking at this question . 尝试看这个问题

These tasks are there in game development where the objects are moved around the screen. 这些任务在游戏开发中就存在,其中对象在屏幕上移动。 You can take a look at this and see how objects are moved on the screen. 您可以对此进行查看,并查看对象如何在屏幕上移动。 On the same lines you can solve your problem. 同样,您可以解决您的问题。

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

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