App/Android
Animation simple example in Android
selfstarter
2020. 3. 30. 11:45
Animation simple example in Android
Android Animation 예제(애니메이션 방식)
- 00~03.png file drop into drawable folder
- Add animation-list file in drawable folder
- write animation image list
- option android:oneshot="true" : if finished animation, it would stop
<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/00" android:duration="20"/> <item android:drawable="@drawable/01" android:duration="20"/> <item android:drawable="@drawable/02" android:duration="20"/> <item android:drawable="@drawable/03" android:duration="20"/> </animation-list>
- add Code in activity_main.xml
<ImageView android:id="@+id/testAnimation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/test_animation" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" />
- add Code in MainActivity
ImageView testImage = (ImageView)findViewById(R.id.testAnimation); AnimationDrawable animationDrawable = (AnimationDrawable)testImage.getBackground(); animationDrawable.start();