2012-07-27 74 views

回答

0

Activity翻轉動畫上不存在Android..sorry!

0

下面是從SDK演示代碼:

/** 
* <p>Example of using a custom animation when transitioning between activities.</p> 
*/ 
public class Animation extends Activity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     setContentView(R.layout.activity_animation); 

     // Watch for button clicks. 
     Button button = (Button)findViewById(R.id.fade_animation); 
     button.setOnClickListener(mFadeListener); 
     button = (Button)findViewById(R.id.zoom_animation); 
     button.setOnClickListener(mZoomListener); 
    } 

    private OnClickListener mFadeListener = new OnClickListener() { 
     public void onClick(View v) { 
      // Request the next activity transition (here starting a new one). 
      startActivity(new Intent(Animation.this, Controls1.class)); 
      // Supply a custom animation. This one will just fade the new 
      // activity on top. Note that we need to also supply an animation 
      // (here just doing nothing for the same amount of time) for the 
      // old activity to prevent it from going away too soon. 
      overridePendingTransition(R.anim.fade, R.anim.hold); 
     } 
    }; 

    private OnClickListener mZoomListener = new OnClickListener() { 
     public void onClick(View v) { 
      // Request the next activity transition (here starting a new one). 
      startActivity(new Intent(Animation.this, Controls1.class)); 
      // This is a more complicated animation, involving transformations 
      // on both this (exit) and the new (enter) activity. Note how for 
      // the duration of the animation we force the exiting activity 
      // to be Z-ordered on top (even though it really isn't) to achieve 
      // the effect we want. 
      overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit); 
     } 
    }; 
} 

所有代碼都是在apidemo /應用/,:)

+0

您能否提供apidemo/app /的鏈接 – 2012-07-27 13:42:38

2

是的,它是可能的。請看這tutorial

以下是關於如何在兩個活動之間轉換時添加動畫的tutorial。但是,並非像文章中那樣使用翻譯動畫,您需要使用旋轉動畫。

+0

好的,讓我查看您發佈的教程。謝謝 – 2012-07-27 12:58:18

+0

使用您發佈的代碼後的動畫是「屏幕閃爍了大約0.25秒,並顯示被叫活動」,它絕不像旋轉或翻轉:( – 2012-07-27 13:05:59

+0

我改變了從「300」到「 3000「只是爲了清楚地檢查實際的動畫,只要我點擊按鈕從ActivityA到ActivityB,屏幕變黑,然後慢慢地出現ActivityA,然後出現ActivityB – 2012-07-27 13:10:48