2013-02-27 62 views
3

我解決它。如果你需要幫助的動畫效果下一個活動,這是我的電子郵件:[email protected]機器人:第一個活動,並在同時間

XML佈局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<RelativeLayout 
    android:id="@+id/newLayout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 
</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/oldLayout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 
</RelativeLayout> 

Java代碼,它需要延長的ActivityGroup:

LocalActivityManager localLocalActivityManager = getLocalActivityManager(); 
    paramIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    Window localWindow = localLocalActivityManager.startActivity("flag", NewActivity.class); 
    localWindow.addFlags(1); 
    View localView = localWindow.getDecorView(); 
    localView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); 
    newLayout.addView(localView); 
dAnimation upOut = AnimationUtils.loadAnimation(this, R.anim.push_up_out); 
    Animation zoomEnter = AnimationUtils.loadAnimation(this, R.anim.zoom_enter); 
newLayout.startAnimation(zoomEnter); 
oldLayout.startAnimation(upOut); 
+0

「當在動畫開始時,底部顯示下一個活動頁面,則動畫的第一頁和下一頁動畫同時開始。」這句話是什麼意思? – akaya 2013-02-27 09:00:07

回答

1

試試這個代碼

button.setOnClickListener(new OnClickListener() { 

     public void onClick(View v) { 

      final View l = findViewById(R.id.main); 

      Animation a = AnimationUtils.loadAnimation(
        YourActivity.this, android.R.anim.fade_out); 
      a.setDuration(200); 
      a.setAnimationListener(new AnimationListener() { 

       public void onAnimationEnd(Animation animation) { 
         // Do what ever you need, if not remove it. 
       } 

       public void onAnimationRepeat(Animation animation) { 
         // Do what ever you need, if not remove it. 
       } 

       public void onAnimationStart(Animation animation) { 
         // Do what ever you need, if not remove it. 
       } 

      }); 
      l.startAnimation(a); 
     } 
    });