我正在尝试移动一个RelativeLayout
using TranslateAnimation
。我为执行相同操作而编写的代码是:
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 视图位置到所需的视图位置执行此操作。
Here heightOfRootView
代表全屏高度,excuseContainer
是我想要用动画移动的视图吗?currentYPoint
是最后一个 y 点excuseContainer
.
编辑:
我有可用的翻译动画教程。我搜索过但没有找到..
感谢您的支持。
第 3 个参数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);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)