How a Translate Animation works: Android

时光怂恿深爱的人放手 提交于 2019-11-30 23:43:02

The 3rd parameter of the TranslateAnimation constructor you are using is a delta value, so the starting point is calculated like:

currentYPos + startingDeltaY

Since you seem to be passing in a Y value that refers to the location of something on the screen, this delta value won't be correct.

Try using this constructor:

public TranslateAnimation (int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue)

Like this:

new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.ABSOLUTE, heightOfRootView-excuseContainer.getHeight(), Animation.ABSOLUTE, currentYPoint);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!