2017-03-07 93 views

回答

0
Animation anim1 = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slide_from_left); 
      anim1.setDuration(1000); // set how long you want the animation 

Animation anim2 = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slide_to_right); 
      anim2.setDuration(1000); // set how long you want the animation 

firstlayout.setAnimation(anim1); 
secondlayout.setAnimation(anim2); 
secondlayout.setVisibility(View.Invisible); 

我設法得到使用上面的代碼的結果。謝謝。

0

使用這個。

this.overridePendingTransition(R.anim.animation_enter, 
       R.anim.animation_leave) 

//

<set xmlns:android="http://schemas.android.com/apk/res/android" 
 
       android:shareInterpolator="false"> 
 
       <translate android:fromXDelta="-100%" android:toXDelta="0%" 
 
      android:fromYDelta="0%" android:toYDelta="0%" 
 
      android:duration="700"/> 
 
       </set>

+0

如果我想只在佈局過渡?因爲看起來像這個解決方案用於啓動新的Intent時製作動畫。 –

+0

你可以使用動畫這個鏈接http://www.androidhive.info/2013/06/android-working-with-xml-animations/ –

+0

它的大概念 –