Android animation slow down on activity transitions - android

I have a FragmentDialog containing an animation composed by two ImageView that I animate indefinitely when App is doing some background work, in other words I use it as a loading dialog. ( I know that loading dialogs that block UI are bad practice in Android but I was forced to do it because I have to do an IOS porting).
This animation is always smooth except during transitions between two activities.
Example : I have to do a login screen and the loading dialog animation must run continuously till the login activity is no more visible and the next activity takes its place.
When the login is at the end , and transition between the two activity starts, the animation slow down and it's very jerky.
I begin the animations with startAnimation(AnimationUtils.loadAnimation(context, R.anim.rotate)); on 2 ImageView.
How can I solve this problem? Thanks in advance

Related

Shared Element Activity Transition having with weird performance

I am using a shared element transition between two activities. I am using this link for animation. Integrated this.
https://github.com/codepath/android_guides/wiki/Shared-Element-Activity-Transition
I am getting something like this. Can anyone tell me why I am getting this kind of screen for a second. Animation in not smooth, but when we press back button back animation as expected smooth.
enter image description here

Can I implement Splash screen in a Fragment?

The main activity is a login page. I have included a splash screen as well. What I want is to apply animation to the splash screen. For that, I am trying to put it in a separate fragment. How can I do this?
I have created a theme and everything that is needed to implement a basic splash screen.
Most of the apps(youtube, facebook etc) don't have an animated splash screen because, all the code initialization drops a lot of frames in your app. These frame drops will be clearly visible if you try to animate the screen.
For your animations to be smooth, a frame has to be drawn every 16ms. Even if one frame is not drawn, users can see the change... what this means is, if you are jumping a ball on ur splash screens.. the easing function you apply to the animation will not work as expected.
Solution:
In your launcher activity, just have a simple ui. As minimal as possible. This will give the user a feeling that app launched quickly. Once your initializations are over, you can attach your fragment which can have the same UI as activity and then make any transition.
In practice:
Launch activity A(launcher) -> UI can be a simple white screen with your logo in the center of the screen.
Once your initialization(all the libraries that load in your Application class like firebase, ORM, analytics tools ect) is over, attach your fragment with a screen containing the same white screen and logo.
This way the user will not know transition from activity to ur fragment as the UI is same. Now you can do any kind of animation in your screen. The initialization time varies from application to application and phone to phone.

Animations between activities hanging

In my app, there are 2 activities. To make the transition seem smooth I animated elements of the first and second activity and disabled transition between the 2 activities. An example of what happens is in the video below:
https://youtu.be/L85HfIUPQuk
The problem as you might see is that, once the animations in the first activity end, there is a period, less than a second but still noticeable, where the screen hangs on the empty white background. Only after that does the second activity and animations start.
The animations are simple alpha and translate effects, nothing fancy.
Any suggestions how to get rid of the hanging period?
You should use Activity Transition.
I think what you need is Shared Elements Transition, since the list from first screen is also on the second screen. Checkout the documentation:
http://developer.android.com/training/material/animations.html

Android Fragment Transition

I am trying to load a fragment which by fragment transation which has slide animation. The sliding effect starts with a delay of about 2-3 seconds after i press the button. I have reduced the heaviness of my UI as much as possible. Also, there are no background processes running? ow to start the sliding effect as soon as I press the button
Try prefetching data so that you don't have to do much processing when starting the fragment. If loading certain information takes some time, do it in the background and display default information like "Retrieving data..."
If you'd like to have a more detailed answer, please post code so we can help.

Custom Splash Screen - Android

Currently my android application shows a black screen with a loading wheel as it processes the user's request i:e as it gets content from the server. I would like to modify this screen to include an icon (image) that fades in and out continuously instead of the loading wheel. Is there any possible way to do it?
Yes, you'll use an Alpha Animation
See here
and here
and lastly here for a good tutorial on Animations with some nice code.
In order to "chain" your animations so that one starts after the other you'll use an Animation listener and start the other one from the onAnimationEnd method callback. Don't forget to put an if statement in there that checks to see if your stuff is done loading otherwise you'll end up with infinite recursion of your fade in and fade out.

Categories

Resources