2011-03-05 4 views
6

나는 활동 (예를 들어 homeActivity)을 가지고 있었고 홈 액션에서 새로운 활동 (nextActivity)을 시작할 때 맨 아래에서 나타나는 것처럼 애니메이션 효과를주고 싶다. 안드로이드에서 가능합니까?animation in 안드로이드

답변

2

Intent.FLAG_ACTIVITY_NO_ANIMATION 플래그를 사용하여 기본 애니메이션 (오른쪽에서 슬라이드)을 금지 할 수 있습니다.

즉 :

Intent myIntent = new Intent(context, MyActivity.class); 
myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); 
context.startActivity(myIntent); 

는 다음 활동에 당신은 단순히 자신의 애니메이션을 지정해야합니다.

6

startActivity으로 전화 한 후 overridePendingTransition의 아이디로 xml 정의 된 애니메이션, 현재 활동 용, 입력 용으로 하나씩 호출하십시오. 이 방법 here

1
TopListActivity topList; 
Vector<BitmapDrawable> images; 
int count = 0; 
public AnimationAlphaTimer(TopListActivity _topList) 
{ 
    this.topList = _topList; 

    this.images = new Vector<BitmapDrawable>(); 
    for (int i = 0; ; i++) { 
    // LOAD IMAGES HERE 
    } 

    if (this.images.size() > 0) { 
    this.topList.slide_0.setBackgroundDrawable(this.images.get(0)); 

    if (this.images.size() > 1) { 
     this.topList.slide_1.setBackgroundDrawable(this.images.get(1)); 
    } 
    } 

    this.count = 1; 
} 

public void launch() 
{ 
    if (this.images.size() >= 2) { 
    (new Timer(false)).schedule(this, 100); 
    } 
} 

@Override 
public void run() 
{ 
    this.doit(); 
    this.cancel(); 
} 

private void doit() 
{ 
    if ((this.count % 2) == 0) { 
    AlphaAnimation animation = new AlphaAnimation(1.0f, 0.0f); 
    animation.setStartOffset(3000); 
    animation.setDuration(3000); 
    animation.setFillAfter(true); 
    animation.setAnimationListener(this); 

    this.topList.slide_1.startAnimation(animation); 
    } else { 
    AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f); 
    animation.setStartOffset(3000); 
    animation.setDuration(3000); 
    animation.setFillAfter(true); 
    animation.setAnimationListener(this); 

    this.topList.slide_1.startAnimation(animation); 
    } 
} 

public void onAnimationEnd(Animation animation) 
{ 
    if ((this.count % 2) == 0) { 
    this.topList.slide_1.setBackgroundDrawable(
     this.images.get((this.count + 1) % (this.images.size())) 
    ); 
    } else { 
    this.topList.slide_0.setBackgroundDrawable(
     this.images.get((this.count + 1) % (this.images.size())) 
    ); 
    } 

    this.count++; 
    this.doit(); 
} 
public void onAnimationRepeat(Animation animation) { 
} 
public void onAnimationStart(Animation animation) { 
}} 

내가 그것을 작동합니다 생각이 시도에 대한 문서를 참조하십시오.