2016-05-03 12 views

Antwort

0

Versuchen Sie, die folgende Zeile nach dem Start der Aktivität hinzufügen:

overridePendingTransition(R.anim.youranimation, R.anim.default_anim); 

Zum Beispiel:

Intent intent = new Intent (context, YourActivity.class); 
startActivity(intent); 
overridePendingTransition(R.anim.youranimation, R.anim.default_anim); 

default_anim.xml:

<?xml version="1.0" encoding="utf-8"?> 

<translate xmlns:android="http://schemas.android.com/apk/res/android" 
    android:duration="@android:integer/config_shortAnimTime" 
    android:fromYDelta="0%p" 
    android:toYDelta="0%p" /> 

Werte ändern.

1

schreiben Sie Ihren Code in oncreate Methode der nächsten Aktivität

1

für Fade-in XML-Datei erstellen Animation, /res/anim/fadein.xml.

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" 
android:interpolator="@android:anim/linear_interpolator"> 
<alpha 
    android:fromAlpha="0.1" 
    android:toAlpha="1.0" 
    android:duration="2000" 
    /> 
</set> 

Erstellen Sie eine XML-Datei für die Fade-Out-Animation, /res/anim/fadeout.xml.

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" 
android:interpolator="@android:anim/linear_interpolator"> 
<alpha 
    android:fromAlpha="1.0" 
    android:toAlpha="0.1" 
    android:duration="2000" 
    /> 
</set> 

In Ihrem Activity

final Animation animationFadeIn = AnimationUtils.loadAnimation(this, R.anim.fadein); 
buttonToNextActivity.setOnClickListener(new Button.OnClickListener(){ 

    @Override 
public void onClick(View arg0) { 
    // TODO Auto-generated method stub 
    image.startAnimation(animationFadeIn); 
    }}); 

Gleiche wie sie schreiben in der SecondActivity finden und rufen Sie die Animation onBackPressed(){...}