액티브 뷰 페이지 효과 제거
public void onCreate(...)
{
//뷰보이기 효과 아무것도 효과 없애기
getWindow().setWindowAnimations(0);
}
페이지 효과가 싫으면 토스트 효과로 부드럽게 보이도록 할수있다.
//뷰페이지가 토스트 효과로 보이게 하기
getWindow().setWindowAnimations(android.R.style.Animation_Toast);
출처: http://www.androidpub.com/1174963
//////////////////////////////////////////////////////////////////////////////////////////////////////
출처: http://androiddeveloper.tistory.com/71
Android - Page move ( 한 Activity에서 페이지 이동효과 주기 )
Android 2011/10/31 15:14/////////////////////////////////////////////////////////////////////////////////////////////////////////////
출처: http://www.androidpub.com/1385434
//////////////////////////////////////////////////////////////////////////////////////////////
출처: http://dotndotandroid.blogspot.kr/2011/05/activity-overridependingtransition.html
Activity 변경 애니메이션 효과 - overridePendingTransition
설정할 수 있다.
사용법도 간단하다.
startActivity(); 를 하고, overridePendingTransition( R.anim.new_activity, R.anim.old_activity );
애니메이션이 설정되지 않은 경우는 새 액티비티는 오른쪽에서 슬라이드-인 되고,
기존 액티비티는 왼쪽으로 슬라이드-아웃 된다.
애니메이션은 기존 방식과 동일하게 res/anim 폴더에 xml 로 작성하던가,
Animation 객체를 생성해 사용해도 된다.
[ fade - animation ]
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@android:integer/config_longAnimTime" />
[ hold - animation ]
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromXDelta="0" android:toXDelta="0"
android:duration="@android:integer/config_longAnimTime" />
[ zoom_enter- animation ]
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator">
<scale android:fromXScale="2.0" android:toXScale="1.0"
android:fromYScale="2.0" android:toYScale="1.0"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="@android:integer/config_mediumAnimTime" />
</set>
[ zoom_exit - animation ]
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"
android:zAdjustment="top">
<scale android:fromXScale="1.0" android:toXScale=".5"
android:fromYScale="1.0" android:toYScale=".5"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="1.0" android:toAlpha="0"
android:duration="@android:integer/config_mediumAnimTime"/>
</set>
///////////////////////////////////////////////////////////////////////////////
출처: http://www.androidside.com/bbs/board.php?bo_table=B46&wr_id=12294
안드로이드 공부하시는 분들은 자신이 만든 어플리케이션이 멋지게 작동하는걸 원하실 겁니다.
그중에하나가 에니메이션이죠.
그런데 에니메이션 하면 보통 ViewFlipper 를 많이들 생각하실겁니다.
하지만 ViewFlipper는 뷰를 컨트롤하는거지 Activity간의 에니메이션을 컨트롤하지는 않습니다.
그래서 있는것이 overridePendingTransition 입니다.
사용 예) overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
인텐트로 넘어갈때 써주시면 됩니다.
다만 아셔야 할것이 있습니다.
이것은 안드로이드 버전과 관련이있더군요.
제가 1.5로 어플을 만드는데 처음에 이걸썻다가 오작동 혹은 오류가 뜨길래 잘못된 정보인줄 알았습니다만,
2.1로 만든 어플에서는 작동이 되었습니다.
아무튼 Activity간의 이동시에 에니메이션을 추가하고싶으시면 overridePendingTransition를 써주시면 됩니다.
////////////////////////////////////////////////////////////////////////////////////////
출처: http://www.androidside.com/bbs/board.php?bo_table=B46&wr_id=15755
다 아시느분도 게시공 도움이 될지 모르겟지만 혹시나 모르시는분들을 위해 올려봄니다^^
보통 화면 전화시에 화면이 기존 화면에서 옆으로 넘어가는 형식의 화면이 전환이 되는데
이렇게 하시면 액티비티간 화면 전환시 좀더 부드럽고 다양하게 화면 전환 효과를 줄수 있습니다
-res폴더 밑에 anim폴드 생성
-anim폴더안에 fade.xml,hold.xml 넣기
*fade.xml*
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@android:integer/config_longAnimTime" />
*hold.xml*
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromXDelta="0" android:toXDelta="1.0"
android:duration="@android:integer/config_longAnimTime" />
-이동전 액티비티의 소스코드에서 다음 액티비티호출하는 부분 startActivity(intent)
밑에 다음 코드를 넣어준다
overridePendingTransition(R.anim.fade,R.anim.hold);
넣어주면 넘어갈때 기존의 화면전환과 다르게 사라지면서 새로운 액티비티로 전환
참고로 이건 1.6버전에서는 가능하지 않더라고요^^
허접한 팀이지만 도움이 되었으면 합니다^^ ㅋㅋㅋㅋㅋ
/////////////////////////////////////////////////////////////////////////////////
출처: http://foobarpig.com/android-dev/how-to-disable-animation-on-startactivity-finish-and-backpressed.html
Disabling Activity “slide” animation on StartActivity, Finish() and BackPressed
This post is about Android development, because I’m currently doing both. Hopefully this year I’ll have enough time to update my blog more frequently. Anyway, back to programming: how to disable “slide” animation on various Activity related events.
Disable animation on StartActivity
Before starting your activity, you have to set flag FLAG_ACTIVITY_NO_ANIMATION to your Intent.
1 2 3 4 | Intent myIntent = new Intent(); myIntent.setClassName( this , ExampleActivity. class .getName()); myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(myIntent); |
Unfortunately, this will not disable animations caused by back button or, if you’ve started SubActivity, on finish().
Disable animation on finish() and back button pressed
After your finish() function put overridePendingTransition(0, 0):
1 2 3 4 | Intent resultIntent = new Intent(); setResult(Activity.RESULT_OK, resultIntent); finish(); overridePendingTransition( 0 , 0 ); |
Same function helps with handling back button animation. Just override onBackPressed in your activity
1 2 3 4 5 | @Override public void onBackPressed() {
this .finish();
overridePendingTransition( 0 , 0 ); } |
Tags: FLAG_ACTIVITY_NO_ANIMATION, onBackPressed, overridePendingTransition, StartActivity
4 responses
'구글과인터넷 > 안드로이드' 카테고리의 다른 글
안드로이드 탭 구현 관련 (0) | 2012.12.12 |
---|---|
안드로이드 컨트롤 포커스 표시관련 (리스트, 버튼 등등) (0) | 2012.12.12 |
안드로이드 웹뷰에서 꽉찬 화면, 크기조정 관련~ (0) | 2012.12.12 |
I have noticed that the onBackPressed() implementation does not always work. For me I still get a swipe for TabActivities.
To overcome this I put the older (legacy) approach in the onCreate method of the Activity that I DON’T want to animate:
public void onCreate(Bundle savedInstanceState) {
…
// Disable all animations
getWindow().setWindowAnimations(0);
}
Thanks! Works like a charm
Thanks.
Instead of adding overridePendingTransition(0, 0) after finish() and overriding onBackPressed(), it’s probably easier to override finish() itself:
@Override
public void finish() {
super.finish();
overridePendingTransition(0, 0);
}
Like this, if later you add another way to “exit” the activity by calling finish(), you don’t have the risk to forget to add the overridePendingTransition()
Awesome! Works great!