2014-04-17 102 views
1

我試圖在活動組之間添加一個轉換,但不起作用。將動畫添加到新活動

我一直在尋找和解決它,但沒有答案爲我工作。

像:

overridePendingTransition not working

Can I change the Android startActivity() transition animation?

Make new activity appear behind old one during transition

我後我的代碼:

在我的MainActivity一個鍵我設置的onclick監聽器。

cobrar.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      Intent formasdepago = new Intent(MainActivity.this, Formas_De_Pago.class); 
      startActivity(formasdepago); 
      overridePendingTransition(R.anim.push_in,R.anim.push_out); 
     } 
    }); 

Push_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator">
<translate android:fromYDelta="100%p" android:toYDelta="0" android:duration="500"/> </set>

Push_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator">
<translate android:fromYDelta="0" android:toYDelta="-100%p" android:duration="500"/> </set>

+0

您是否想在每次活動開始時或剛剛從某些地方調用時動畫?如果每次都將您的'overridePendingTransition'放入正在啓動的Activity的onCreate中。 – dharms

+0

我想在每次點擊按鈕「cobrar」時製作動畫。 – Rogui

+0

我想在onCreate中放置overridePendingTransaction! – Rogui

回答

2

是我的電話,我不得不關閉該選項的問題:

設置 - >開發人員選項 - >轉換動畫比例尺