Android transition not working on phone - android

I created some transitions between activities that are working fine in the emulator, but nothing of them can be seen on the phone (neither fade in-out nor slide). The new activity simply appears like I have not implemented any transitions. Why is that?
fadein.xml
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="1000" />
fadeout.xml
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/accelerate_interpolator"
android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="1000" />
And i set in the appropriate activity
overridePendingTransition(R.anim.fadein, R.anim.fadeout);

Make sure that animations are enabled on device. For this go to Settings->Display->Animations and select "All Animations".

Enable the transition animation
Settings -> Developer Options -> Transition Animation Scale -> 1x

Go to Settigs then developer options and check for the options that are related to animation and assure that each one of animation option is switched on

Related

Activity transition black screen

So I've got WelcomeActivity -> HomeActivity and closing WelcomeActivity with finish()/supportFinishAfterTransition(). I want to do either a slideTransition or a fadeTransition (open to other suggestions btw).
I've researched this and as it turns out there are 2+ ways of doing it: either with overridePendingTransition which uses anim.xml files or with Transitions (from the android docs) which use transition.xml files...
I've tried both and both give me unwanted results:
for anims: I get this ugly mid transition black screen:
fade_in.xml:
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/accelerate_interpolator"
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="300" />
fade_out.xml:
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/accelerate_interpolator"
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:zAdjustment="top"
android:duration="300" />
WelcomeActivity: (I've tried having finish before the overridePendingTransaction)
startActivity(Intent(this, HomeActivity::class.java))
overridePendingTransition(R.anim.fade_in, R.anim.fade_out)
finish()
for transitions: I can't make it so WelcomeActivity closes properly: It either closes before the animation starts or not closing at all. I'm following the android docs.. I've also tried this:
style.xml
<item name="android:windowActivityTransitions">true</item>
<item name="android:windowEnterTransition">#transition/enter_fade</item>
<item name="android:windowExitTransition">#transition/exit_fade</item>
My other questions is which approach should I have? Is Google pushing the transitions over the anims for starting new activities?
What I always do is to start an activity(any way you want, ways are listed here).
I use slide transitions using these two files:
slide_out_left.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="#android:integer/config_mediumAnimTime"
android:fromXDelta="0"
android:toXDelta="-100%p" />
</set>
slide_in_right.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="#android:integer/config_mediumAnimTime"
android:fromXDelta="100%p"
android:toXDelta="0" />
</set>
Then I start an activity like this(this is java):
startActivity(MainActivity.this, SecondActivity.class);
overridePendingTransition(R.anim.slide_in_right.xml, R.anim.slide_in_left.xml);
finish();
Using this, the activity exits giving way to the new one smoothly from right to left.
For the black screen, set the theme of that activity as translucent in the AndroidManifest.xml file
android:theme="#android:style/Theme.Translucent"
so your code will be something like this
<activity android:name=".Activity"
android:theme="#android:style/Theme.Translucent" />
Answer for the black screen taken from: https://stackoverflow.com/a/6468734/9819031

support-v4:27.1.0 fragment custom animations do not work as expected

Fragment animations do not work properly with support-v4:27.1.0
getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(ENTER_ANIM , LEAVE_ANIM)
.replace(R.id.main_activity_fragment_place_holder, fragment)
.addToBackStack(tag)
.commitAllowingStateLoss();
enter animation
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="500" />
leave animation
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/accelerate_interpolator"
android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="500" />
I just hit the same problem. Support library 27.1.0 seems to have a problem with anim transitions that use the alpha property.
My impression is that the transition engine does not correctly implement a "fill-after", so that the fragment alpha quickly bounces back to 1 before the fragment is removed. This causes a blinking effect where the replaced fragment is briefly visible and then disappears.
I resolved the issue switching to animator transitions.
I.e. replaced my /res/anim/fade_in.xml
<?xml version="1.0" encoding="utf-8"?>
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="0"
android:toAlpha="1"
android:duration="500"
/>
with an analogous /res/animator/fade_in.xml
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="alpha"
android:valueFrom="0"
android:valueTo="1"
android:duration="500"
/>
I did the same for the fade_out transition.
The blinking effect was fixed in the latest support library version 27.1.1. (see issue 74051124)
I have the exact same problem after upgrading the support library from 27.0.2 to 27.1.0. Instead of fading smoothly, the fragments blink several times.
It seems that all animators work as expected, except alpha animators.
However, I have found a workaround for this bug: If you disable the enter animation, the transition still fades. It does not fade in the exact same way as before, but it looks good (or even better) in my opinion.
The new enter animation (which I have named nothing.xml) is:
<?xml version="1.0" encoding="utf-8"?>
<set/>

Android fade in , fade out animation issue

I'm trying to customize the animation between two activities by fading out the splashscreen and fading in the main activity.
I trying two solutions, one with fade_in.xml and fade_out.xml where controlling alphas (0-1 , 1-0) and calling everything with overridePendingTransaction(fade_in, fade_out) and one with fade and hold like ni api demo (api/app/animation/fade);
The main problem is that the splashscreen (first animation ) is losing its alpha while sliding to the right as well and the second activity is appearing as wanted.
How is possible to lock the splashscreen to its original position and just making it fading out?
fade
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="#android:integer/config_longAnimTime" />
hold
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/accelerate_interpolator"
android:fromXDelta="0" android:toXDelta="0"
android:duration="#android:integer/config_longAnimTime" />
overridePendingTransition(R.anim.fade, R.anim.hold);
You can use the callback for .fadeOut().

overridePendingTransition doesn't work

Have found already some people asking the same, but the solutions didn't work for me.
I see no animation.
Calling it this way:
Intent intent = new Intent(this, MyActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
fadein.xml and fadeout.xml are in the anim folder:
fadein.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<alpha
android:duration="1000"
android:fromAlpha="0.0"
android:interpolator="#android:anim/accelerate_interpolator"
android:toAlpha="1.0" />
</set>
fadeout.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="1000"
android:fromAlpha="1.0"
android:interpolator="#android:anim/accelerate_interpolator"
android:toAlpha="0.0" />
</set>
Using min. API 7:
manifest:
<uses-sdk android:minSdkVersion="7"/>
API 7 is also in my project.properties file:
target=android-7
What am I doing wrong?
P.D. Removing the lines with the interpolator doesn't change anything.
Already seen / tried:
overridePendingTransition doesn't work
overridePendingTransition does not work when FLAG_ACTIVITY_REORDER_TO_FRONT is used
Fade in Activity from previous Activity in Android
Fade in Activity from previous Activity in Android
Activity transition in Android
The problem was that the device, at least in the case of Samsung Galaxy, has to have animations enabled for this to work. This can be done in the settings menu.
You need to make sure that you havn't turned it off in the device using the Settings > Developer Options:
you should turn on Transition animation scale.
As you said in some Samsung devices (maybe others to) the option "All animations" in Settings->Display->Animation ha to be selected and not the default "Some animations"
The problem that might be happen to you, for animation doesn't work, it's because your current activity is different from the next activity you intent to. And instead to make the animation he destroy the current activity, and therefor the animation doesn't show, make sure that your both activity's are in the same orientation.

Is there any way to find what is the default activity transition animation?

I need to changed Layouts in my activity ( lot off them in one activity ). I put animations between like
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="#android:anim/accelerate_interpolator">
<translate
android:fromXDelta="100%"
android:toYDelta="0"
android:duration="300" />
<alpha
android:fromAlpha="0.1"
android:toAlpha="1.0"
android:duration="300" />
</set>
Is there any way to find what is he default activity transition animation on phone ?
By "standard-default animation" you mean the default activity transition animation ? If so, it's phone (or vendor) specific.
Yes. Different smart phone manufacturers customize a little bit on the Android OEM version.

Categories

Resources