Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/213.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
翻译动画的工作原理:Android_Android_Android Animation_Translate Animation - Fatal编程技术网

翻译动画的工作原理:Android

翻译动画的工作原理:Android,android,android-animation,translate-animation,Android,Android Animation,Translate Animation,我正在尝试使用TranslateAnimation移动相对值yout。我为执行相同操作而编写的代码是: translateAnimation = new TranslateAnimation(0, 0, heightOfRootView-excuseContainer.getHeight(), currentYPoint); translateAnimation.setRepeatMode(0); translateAnimation.setDuration(500); translateAni

我正在尝试使用
TranslateAnimation
移动
相对值yout
。我为执行相同操作而编写的代码是:

translateAnimation = new TranslateAnimation(0, 0, heightOfRootView-excuseContainer.getHeight(), currentYPoint);
translateAnimation.setRepeatMode(0);
translateAnimation.setDuration(500);
translateAnimation.setFillAfter(true);
excuseContainer.startAnimation(translateAnimation);
我试图从特定视图的当前y位置开始动画 (我不需要更改视图的x位置) 但动画每次都从第一个y点开始。如何从视图的当前y位置到所需的视图位置执行此操作

这里,
heightOfRootView
代表全屏的高度,
excuseContainer
是我想用动画移动的视图,
currentYPoint
excuseContainer
的最后一个y点

编辑: 我没有任何翻译动画教程可用。我找过了,但没找到


感谢您的支持。

您正在使用的
TranslateAnimation
构造函数的第三个参数是一个增量值,因此起点的计算方式如下:

currentYPos+startingDeltaY

由于您似乎要传入一个
Y
值,该值表示屏幕上某物的位置,因此此增量值将不正确

尝试使用此构造函数:

公共翻译映像(int-fromXType,float-fromXValue,int-toXType,float-toXValue,int-fromYType,float-fromYValue,int-toYType,float-toYValue)

像这样:

new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.ABSOLUTE, heightOfRootView-excuseContainer.getHeight(), Animation.ABSOLUTE, currentYPoint);

“第一个y点”是什么意思?你能在你的应用程序的屏幕截图上画些什么吗?我指的是加载应用程序时视图最初放置的位置。我们能从特定点开始窗口的动画并在屏幕上打开吗?例:从按钮下方的点打开的窗口,覆盖按钮下方的窗口。