I am codifiying a transition effect between my logo activity and my Main activity, but I have the problem that before vanish the activity move to top:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<alpha
android:duration="2000"
android:fromAlpha="0.0"
android:toAlpha="1.0" >
</alpha>
</set>
How could I improve this code to get only a vanish effect?
This question is related to
android
animation
android-intent
pending-transition
you can also add animation in your activity, in onCreate method like below becasue overridePendingTransition is not working with some mobile, or it depends on device settings...
View view = findViewById(android.R.id.content);
Animation mLoadAnimation = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in);
mLoadAnimation.setDuration(2000);
view.startAnimation(mLoadAnimation);
you can also use this code in your style.xml file so you don't need to write anything else in your activity.java
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowAnimationStyle">@style/AppTheme.WindowTransition</item>
</style>
<!-- Setting window animation -->
<style name="AppTheme.WindowTransition">
<item name="android:windowEnterAnimation">@android:anim/fade_in</item>
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
</style>
Just re-posting answer by oleynikd because it's simple and neat
Bundle bundle = ActivityOptionsCompat.makeCustomAnimation(getContext(),
android.R.anim.fade_in, android.R.anim.fade_out).toBundle();
startActivity(intent, bundle);
Source: Stackoverflow.com