如何建立动画在XML滑动向上/向下为Android?动画、XML、Android

由网友(人若深情必自毙)分享简介:我一直在试图找出如何建立一个动画师(XML),这将导致向上滑动和向下滑动的效果。如何将这项工作?谢谢I've been trying to find out how to build an animator (xml) that will cause a slide up and slide down effect....

我一直在试图找出如何建立一个动画师(XML),这将导致向上滑动和向下滑动的效果。如何将这项工作?谢谢

I've been trying to find out how to build an animator (xml) that will cause a slide up and slide down effect. How would that work? Thanks

推荐答案

请在该项目的资源文件夹中的文件夹阿尼姆。 现在添加slide_up.xml为slide_up动画。 然后添加slide_down.xml的滑下动画。

Make a folder anim in the res folder of the project. Now add slide_up.xml for slide_up animation. Then add slide_down.xml for slide down animation.

$ C $下slide_down.xml:

Code for slide_down.xml:

<set xmlns:android="http://schemas.android.com/apk/res/android">  
    <translate android:fromXDelta="0" android:fromYDelta="-1000" android:duration="1500"/>
</set>

$ C $下slide_up.xml:

Code for slide_up.xml:

<set xmlns:android="http://schemas.android.com/apk/res/android">  
    <translate android:fromXDelta="0" android:fromYDelta="1000" android:duration="1500"/>
</set>

然后加载动画onCreate方法因此:

Then load the animation in onCreate method consequently:

Animation slideUp = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_up);

要启动它,将其附加你想成为动画对象:

To start it attach it to object you want to be animated:

ImageView img = (ImageView) findViewById(R.id.img);
img.startAnimation(slideUp);

希望我帮助你。 : - )

Hope I've helped you. :-)

阅读全文

相关推荐

最新文章