View 화면이 상, 하, 좌, 우에서 날라 들어오거나 다시 들어가는 간단한 애니메이션이 필요해서 검색 중 http://developer.android.com/guide/topics/graphics/view-animation.html 를 발견하게 되었다.
이를 응용해서 현재 개발중인 프로젝트에 사용하였다.
관련 소스는 아래와 같다.
자세한 소스 분석은 언제나 그렇듯이 알아서 ^^
res/anim 아래 animation xml 파일을 만든다. 아래와 같이 from x가 100%에서 시작하면 오른쪽에 숨어 있다가 to x인 0의 위치, 즉 원래 화면 안으로 들어오는 부분이다. 따라서 이름도 slide_in_from_right.xml로 만들었다.
이처럼 100%, -100% 그리고 X, Y만 바꿔가면 상, 하, 좌, 우 애니메이션을 만들 수 있다.
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="100%p"
android:toXDelta="0" />
그리고 나서 위 링크에서 볼 수 있는 것처럼 아래와 같이 사용하면 된다.
Animation inFromRightAni = AnimationUtils.loadAnimation(this, R.anim.slide_in_from_right);
view.startAnimation(inFromRightAni);
'Java > Android' 카테고리의 다른 글
listView 내에서 각 row 객체에 접근하기 (0) | 2013.09.25 |
---|---|
EditText에 focus 됬을 때 submit button 보이게 하기 (0) | 2013.09.09 |
ADB를 이용한 /data 디렉토리 접근 (0) | 2013.09.03 |
GPS 좌표를 이용한 거리 구하기 (0) | 2013.07.29 |
에뮬레이터에서 HAX 관련 오류 삽질기 (1) | 2013.05.21 |