Android:ViewAnimation
lastmod 2018-08-17created 2016-05-141 edits
Using Animation resources
In Android, animations are also registered as resources. They are stored as XML-format documents under the project folder \res\anim\, and Java accesses compiled animation resources with AnimationUtil:loadAnimation(context, int). 1
The main XML Elements and Attributes used in the XML document are as follows.
- <translate>
- Specifies an up/down/left/right movement animation. Corresponds to the TranslateAnimation class.
- With the following 4 xml attributes
- android:fromXDelta: X coordinate where the animation starts
- android:toXDelta: X coordinate where it ends
- android:fromYDelta: Starting Y location.
- android:toYDelta: Ending Y location.
- -100% ~ 100%: Ratio of the position relative to itself. 0% is its current position.
- -100%p ~ 100%p: Ratio of the position relative to the parent container. 0%p is its current position.
- float value: Indicates an absolute position.
- Adjusts transparency. Corresponds to the AlphaAnimation class.
- With the following xml attributes
- android:fromAlpha: Transparency when the animation starts
- android:toAlpha: Transparency when the animation finishes
- Set with the following values.
- 0.0 ~ 1.0 (0.0 is transparent, 1.0 is fully opaque)
In addition, the attribute shared by both elements above (translate, alpha) that sets how long the animation lasts is as follows.
-
android:duration: Sets the time from when the Animnation starts until it ends, in milliseconds (1/1000 second).
Favorite site
References
-
Uses
'R.anim.animation_xml_file_이름'↩