Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between ViewPropertyAnimator's translateYBy() vs yBy() methods?

ViewPropertyAnimators (http://developer.android.com/reference/android/view/ViewPropertyAnimator.html) have two types of methods to move Views around:

translateX() vs x(), translateY() vs y(), translateXBy() vs xBy() and finally translateYBy() vs yBy().

Can someone tell me the difference between these methods?

like image 381
Some Noob Student Avatar asked Apr 28 '14 23:04

Some Noob Student


1 Answers

The documentation states that X and Y properties are absolute positions, while translationX and translationY are referred to the LEFT and TOP properties respectively.

So, the difference between animate().x() and animate().translationX() is that one animates to an absolute value, while the other animates to a still absolute value but determined by the view LEFT and TOP values.

By contrast, animate().xBy() and animate().translationXBy() increase (algebraically) the property value by the specified amount.

That is the origin of the "some mathematics" cited above.

like image 136
Nicolò Parolini Avatar answered Sep 19 '22 16:09

Nicolò Parolini