Make new activity appear behind old one during transition
Actually, I've found a property called android:zAdjustment
in the animation files.
If I put android:zAdjustment="bottom"
in hold.xml
(screen 2) and android:zAdjustment="top"
in push_down_out.xml
(screen 1) then I can get the desired effect.
This gets around the z order issue (I assumed it was an issue with animation timings so I was barking up the wrong tree).
John
Android new fragment appears below old one during fragment animation
If fragment appears below another one is because the fragment container is not the good container type
You need to put fragment inside FrameLayout or RelativeLayout, if you want to test you can paste your fragment layout code at the bottom of the fragment container for have a preview
How to change the way a new activity starts in android?
You can use the overridePendingTransition()
method in Activity class to change the transition.Here are a good tutorial for this topic, the link.
But I should mention the point that animation can be disable in phone setting and in this situation your animation transition wont show.
Can I change the Android startActivity() transition animation?
In the same statement in which you execute finish(), execute your animation there too. Then, in the new activity, run another animation. See this code:
fadein.xml
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<alpha android:fromAlpha="1.0"
android:toAlpha="0.0"
android:duration="500"/> //Time in milliseconds
</set>
In your finish-class
private void finishTask() {
if("blabbla".equals("blablabla"){
finish();
runFadeInAnimation();
}
}
private void runFadeInAnimation() {
Animation a = AnimationUtils.loadAnimation(this, R.anim.fadein);
a.reset();
LinearLayout ll = (LinearLayout) findViewById(R.id.yourviewhere);
ll.clearAnimation();
ll.startAnimation(a);
}
fadeout.xml
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<alpha android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="500"/>
</set>
In your new Activity-class you create a similiar method like the runFadeAnimation I wrote and then you run it in onCreate and don't forget to change the resources id to fadeout.
Add animation to new Activity
The problem was my phone, I had disable this option:
Settings->Developer options -> Transition animation scale
How to override onBackPressed() with overridePendingTransition() animation
According to documentation, the first argument to overridePendingTransition
is the animation used for the incoming activity, ie. your MainActivity
. And the second argument is used for the outgoing activity, ie. your PlayPanel
.
play_panel_close_background.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:zAdjustment="top">
<translate
android:fromYDelta="0%"
android:toYDelta="100%"
android:duration="600"
/>
</set>
@Override
public void onBackPressed() {
//super.onBackPressed();
startActivity(new Intent(this, MainActivity.class));
overridePendingTransition(
0,
R.anim.play_panel_close_background
);
}
Related Topics
Why So Complex to Set Style from Code in Android
How to Set Recyclerview App:Layoutmanager="" from Xml
Android - Copy Existing Project with a New Name in Eclipse
Waiting for Target Device to Come Online
How to Have a Listview/Recyclerview Inside a Parent Recyclerview
Scale Fit Mobile Web Content Using Viewport Meta Tag
Android:How to Upload .Mp3 File to Http Server
How to Handle Oncontextitemselected in a Multi Fragment Activity
Android: Why Must Use Getbasecontext() Instead of This
How to Read Properties Defined in Local.Properties in Build.Gradle
Android: How Handle Message Error from the Server Using Volley
What Should Be the Color of the Ripple, Colorprimary or Coloraccent? (Material Design)
Okhttp Response Callbacks on the Main Thread
How to Pass Custom Component Parameters in Java and Xml
Configure Eclipse to Use Signed Keystore
Change Expandable Indicator in Expandablelistview
What Are the Overheads of Using Autoincrement for SQLite on Android