i have a launcher activity which shows up the blank screen at the start up..i want to show up some animation using an animatd.gif...i initialize my layouts viz home etc when the oncreate of launcher is called, but how do i add some animated image until my first layout is shown..i also doubt whether android supports animated gifs or i have to do a workaround.
Animated gifs are not supported for multiple reasons like "animated .gif are memory hogs", the workaround must be an animation
https://developer.android.com/guide/topics/resources/animation-resource.html
Related
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.
I have completely lost my focus now.
I was trying to create a transparent background to show users phone screen like this.
https://market.android.com/details?id=net.kreci.crackedscreen&hl=en
Now i got it working. But i want to now add an image but it wont show till after the click.
Can this be done in Viewflipper with showing the activity Transclucent then showing image after the click? (cause i dont want the screen to flip to another activity, I want it to show straight away)
So technically if you don't understand what I meant.... Similar to the market link i added in this post.
I don't have knowledge regarding ViewFlipper class to implement in this situation,
But
I have one Idea to implement while creating two different activities to show 2 Images.
In onCreate of both activities write the below line right after super.onCreate()
getWindow().setWindowAnimations(0);
This will set Window Animation to 0 so your screen will be changed without any effects.
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.
I'm trying to start an activity and create the transition as a 3d flip (as many have stated exactly like on the IPhone), unfortunately I haven't found a satisfying answer yet and I am stuck.
I've implemented http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html
for the whole layout so that now when pressing a certain button the layouts are flipped, but since it refers to layout that are in activities which weren't loaded, they don't fill all their items and data (an expandable list view for example).
But when i call startActivity() after the flip the activity is created which of course hides the framelayout container on the caller activity - so i can't flip back... (I've used the overridePendingTransition but imho it shouldn't matter).
I could really use your help am losing my mind...
Thanks!
Sorry you can't do this -- the window manager currently only supports 2d animations.
I also want to flip activity as 3D animation. I just found this solution http://blog.robert-heim.de/karriere/android-startactivity-rotate-3d-animation-activityswitcher/
What they does.. startActivity with no animation any apply 3D rotation on it.
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.