Can I implement Splash screen in a Fragment? - android

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.

Related

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

How can I show an animated full screen View over the rest of the UI and View Hierarchy in Android?

I am trying to figure out how to handle this UI feature where I want to make a ViewPager just appear over everything, scroll through the page items, and then when you press back it goes away. Normally I would just use a full screen dialog for this, but I want to apply a combination fade animation (fade in on appear and fade out on disappear) as well as a scale animation (scale up from nothing to fullscreen on appear and scale down from fullscreen to nothing on disappear).
Dialogs seem to be a lot less animation friendly based on the Dialog and Animation interfaces compared to Views. Then again, I don't know how to make a View just sit on top of everything since that's normally what Dialogs are for. Seems hard to tell which is the lesser evil, but I could potentially benefit more from having a full screen View over everything else. What would I need to do?
Edit: A point brought up by #sound-conception I should make clear, that sadly due to the application context for this feature, making this a separate activity is not an option right now.
You state in your question that the ViewPager will be a full screen view. In that case you could implement the ViewPager as a seperate Activity and use Activity Transitions.
Check out this Google I/O developer video on Activity Transitions.
There's also lots of info on the Developer Website

Android animation slow down on activity transitions

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

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.

Android - Fadeout animation for splash screen

I want to add fadeout animation for my splash screen, that is while closing the splash screen I want to bring the fadeout animation effect.
Here are the codes which I have tried.
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
But the above can be used only from 2.0. Ny app should support from 1.5.
So I have set the following animation for my main activity.
getWindow().setWindowAnimations(android.R.style.Animation_Toast);
OR
getWindow().setWindowAnimations(R.style.Theme_FadeIn);
My Theme.FadeIn contains
<style name="Theme.FadeIn">
<item name="android:windowNoTitle">true</item>
<item name="android:activityOpenEnterAnimation">#anim/fade_in</item>
</style>
Now I can see the fadein effect, but I can see the blackscreen.
How to get this fadein or fadeout effect without blackscreen.
You could try to make your activity translucent... take a look at the translucent theme in the sdk
#android:style/Theme.Translucent
SWDeveloper,
While it has been about a year since I have done any Android development myself, I remember running into this exact problem with my own splash screen.
Unfortunately, for releases before 2.0, I'm fairly certain that the type of transition you want is not possible between activities. That is, in 1.5/1.6, only the built in transition animations can be used between activities.
With that being said, I seem to recall that I used view transition animations within a given activity to produce the kind of effect I was looking for. In otherwords, on my splash screen activity, fading out the initial view to just a blank white view before transitioning to the next activity. The next activity would then start on a blank white view and then fade into the actual view of the activity.
If this seems like a lot of work, you could also alternatively just include your splash screen view in your initial activity and always present it first then fade it out. All within the same activity. Using this method would probably save you time and work, but would lose you some of the modularity that comes with separating out your screens into separate activities.
The animations between views can be achieved (if I remember correctly) via the ViewFlipper widget. The android docs for it can be found here:
http://developer.android.com/reference/android/widget/ViewFlipper.html
If I can get a hold of the code base of the app that I wrote, I will try to post up an example later.
Good luck!
If you're using a separate Activity for your splash screen, you can do the overridePendingTransition call that you've noted is available in Android 2+ only. You can choose to have apps that are built for 2+ do the transition and previous versions simply do the default transition:
try {
Method method = Activity.class.getMethod("overridePendingTransition", new Class[]{int.class, int.class});
method.invoke(youractivity, inanimation, outanimation);
} catch (Exception e) {
// Can't change animation, so do nothing
}
It's better to have your splash screen a part of your main Activity (see this example). When the splash screen is part of your main activity, you can simply assign the animation to the splash screen layout.

Categories

Resources