Ich habe eine App und ich möchte eine activity
mit this transition öffnen (Google Maps tut dies auch, wenn Sie die Einstellungen öffnen).Android - So öffnen Sie eine Aktivität mit dem Maßstab und Fade-Effekt
Wie kann ich das erreichen?
Ich habe eine App und ich möchte eine activity
mit this transition öffnen (Google Maps tut dies auch, wenn Sie die Einstellungen öffnen).Android - So öffnen Sie eine Aktivität mit dem Maßstab und Fade-Effekt
Wie kann ich das erreichen?
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.
schreiben Sie Ihren Code in oncreate Methode der nächsten Aktivität
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(){...}