What is the difference between property and state?

From A beginners guide to implement Android Animations 

View Animations — They are used to do simple animations like changing size, position, rotation, control transparency. They are easy to build and are very fast but have their own constraints. For eg — Their state changes but their property does not change. View animations will be covered in part 2.

From what I understand, there are properties and states for Views. What is the difference?

1 answer

  • answered 2018-11-08 06:59 Sweeper

    If your continue reading that same page:

    The problem with View Animations is that, though the View state changes, its property still remains at the original position. That means, if a ImageButton is moved from 0 to 100 pixels to the right, though it will animate to right, the touch(property) of image button will still be at 0th position.

    In other words, property animation changes a property of a view. This can be translationX or translationY or alpha. The ValueAnimator gives you a new value for that property each frame, and you are setting that property to that value. When you translate the view, the view is actually moving.

    View animations are different. They only changes the apparent appearance of the view. Say for example you did a ScaleAnimation, you wouldn't see a change in the view's top and left properties. You'll only see that the view enlarges or shrinks. Its frame, as far as the View object is concerned is not changed.

    I don't remember "state" and "property" as official android terms. It might just be terminology that only that article uses.