애니메이션 xml 코드 ( ex- bomb_ani.xml )
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
레이아웃 xml 내부에 들어갈 ImageView 코드
<ImageView android:id="@+id/bombAni"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
액티비티 java 코드에 들어갈 코드
onCreate()안에 들어갈 내용
ImageView bombAni = (ImageView)findViewById(R.id.bombAni);
bombAni.setBackgroundResource(R.anim.bomb_ani);
AnimationDrawable fanim = (AnimationDrawable) bombAni.getBackground();
이렇게 지정 해준 다음에 외부에서 버튼 클릭시나 특정 이벤트 발생 시에
fanim.start(); 나 fanim.stop(); 으로 애니메이션 정지, 작동이 가능하다.
참고자료
http://developer.android.com/guide/topics/graphics/view-animation.html
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<item android:drawable="@drawable/bomb1" android:duration="50"/>
<item android:drawable="@drawable/bomb2" android:duration="50"/>
</animation-list>
<ImageView android:id="@+id/bombAni"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_centerHorizontal="true"
/>
액티비티 java 코드에 들어갈 코드
onCreate()안에 들어갈 내용
ImageView bombAni = (ImageView)findViewById(R.id.bombAni);
bombAni.setBackgroundResource(R.anim.bomb_ani);
AnimationDrawable fanim = (AnimationDrawable) bombAni.getBackground();
이렇게 지정 해준 다음에 외부에서 버튼 클릭시나 특정 이벤트 발생 시에
fanim.start(); 나 fanim.stop(); 으로 애니메이션 정지, 작동이 가능하다.
참고자료
http://developer.android.com/guide/topics/graphics/view-animation.html
'공부 > Android' 카테고리의 다른 글
안드로이드에서 휠 모양 입력 구현 (0) | 2011.06.07 |
---|---|
안드로이드 액션바 어디서든 사용하기 (0) | 2011.06.05 |
안드로이드 HTML 파싱법 (0) | 2011.06.04 |
안드로이드 커스텀 버튼 (0) | 2011.01.04 |
안드로이드 메모장 튜터리얼 하기 (0) | 2010.08.24 |