2021. 3. 31 작성
#0 Tweened Animation이란?
연산을 통해서 Animation 효과를 만드는 방법을 말합니다.
쉽게 풀어서 얘기하면 view의 위치를 이동, 회전, 확대/축소, 투명도 조절을 할 수 있습니다.
해당 애니메이션을 적용할 수 있는 대상은 View나 layout이며, 보통 xml로 동작을 지정하고, AnimationUitls.loadAnimation()을 이용하여, view에 적용합니다.
#1 트윈 애니메이션의 종류
트윈 애니메이션의 종류는 크게 5가지로 나뉘게 됩니다.
- 회전 (rotate) : 중심점(pivot)을 기준으로 회전하는 애니메이션
- 크기 (scale) : 중심점(pivot)을 기준으로 크기가 커지거나 줄어드는 애니메이션
- 투명도 (alpha) : View가 흐려지거나 다시 진해지는 애니메이션
- 이동 (translate) : View가 상,하,좌,우로 이동하는 애니메이션
- 복합 애니메이션 (set) : 여러 애니메이션을 중첩하는 애니메이션
#2 회전 - rotate
대상을 한점 기준으로 회전시킵니다.
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="3000"
/>
</set>
#3 크기 - scale
확대 축소를 하는 action은 scale을 이용합니다.
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2500"
android:pivotX="50%"
android:pivotY="50%"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="2.0"
android:toYScale="2.0" />
#4 투명도 - alpha
뷰의 투명도를 결정하며 0.0~1.0 사이의 값을 같습니다. (0 = 완전투명, 1 = 완전 불투명)
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="10000" />
</set>
#5 이동 - translate
위치이동은 view나 layout을 한곳에서 다른곳으로 부드럽게 이동시킵니다
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0%p"
android:toXDelta="100%p"
android:duration="5000"
android:repeatCount="1"
android:fillAfter="true" />
</set>
'IT > Android (안드로이드)' 카테고리의 다른 글
Android N.4-1 Wandering in Google maps with Kotlin (0) | 2025.04.21 |
---|---|
Android N.3-6 Using MotionLayout to Animate Android Apps (0) | 2025.04.21 |
Android N.3-4 Clipping Canvas Objects (0) | 2025.04.21 |
Android N.3-3 Drawing on Canvas Object (0) | 2025.04.21 |
Android N.3-2 Creating Custom Views (0) | 2025.04.21 |