selfstarter

Animation simple example in Android 본문

App/Android

Animation simple example in Android

selfstarter 2020. 3. 30. 11:45

Animation simple example in Android

Android Animation 예제(애니메이션 방식)

  1. 00~03.png file drop into drawable folder
  2. Add animation-list file in drawable folder
  3. 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>
  1. 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" />
  2. add Code in MainActivity
    ImageView testImage = (ImageView)findViewById(R.id.testAnimation);
    AnimationDrawable animationDrawable = (AnimationDrawable)testImage.getBackground();
    animationDrawable.start();

Android Animation doc

'App > Android' 카테고리의 다른 글

Setting String format in Android  (0) 2020.04.01
Internal error in Firestore (0.6.6-dev)  (0) 2020.04.01
Simple Current Time Example  (0) 2020.03.26
BroadcastReciver app to app in Android  (0) 2020.03.18
Using Android getIdentifier  (0) 2020.03.12
Comments