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.
Related
This question already has an answer here:
How can I display a Progress at start up application in android
(1 answer)
Closed 5 years ago.
I have a heavy user interface that can delay the application load. I want to show an preloader before the UI of activity loaded. note that my ui is in xml file
EDIT:
If you want to load 10 tabs in a view pager, use a FragmentStatePagerAdapter which only loads neighboring tabs(default behavior).
If the heavy UI you specify is only the UI elements, then the app must freeze while loading it. So you'd better show a non-cancelable dialog(without animation) with loading message and after a few moment (like 200ms) load up your UI and explicitly dismiss the dialog.
But if the heavy stuffs is not just UI, maybe some calculations or image processing, just do it in a background thread while showing a dialog with progress and cancel the dialog when the task is done.
#Hassan according to me if on clicking the launcher icon if it takes sometime for your application to render the first screen(perhaps giving a black screen in between). This needs to be corrected in your application.
On the contrary if your applications main screen requires population/retrieval of certain resources for effectively engaging the users, You can possibly do something like a splash screen(outdated) where you do all "population/retrieval" and then simply pass data to your heavy UI.
Now regarding the progress bar if this fetching of data is small, you can give an indeterminate "custom"(some moving animation that would suite your app) progress bar,else if its something like a download you can easily track its progress and show in a horizontal progressbar
You sure can! You are describing a preloader. Here is a nice example of one https://github.com/rtheunissen/md-preloader
You'll have to add more info to your question to get a specific answer, but there are a few basic principles.
You make your life a lot easier if you use a preloader which doesn't show progress of the load, it just goes round and round, because the speed of some load processes can't be measured.
If its a data-load which is taking the time (such as a call to an API), you might want to set a variable for "loading" to true at the top of your script, then when the data has resolved, set it to "false". In your view, have a state or a conditional element which hides / unhides the preloader.
If lots of images are slowing down the page, you might want to look into "lazy-loading" or using "infinite scroll" to only show content when the UI needs to display it on screen.
Thats all the info I can give without more information on the code you have so far. Hope that helps!
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 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
sorry for the confusing title. I will try to explain my problem.
My app displays some content day-wise in a ListView. The user is able to switch days back and forth (e.g. by swiping his finger to the left/right). Now I want to implement some nice transition effect (like the new Android market has).
The problem is, that the content is generated dynamically and it can take a while to load. Also you can move (theoretically) infinite days to to past or to the future.
How can I implement a nice looking transition that is responsive and also tells the user, that some work is done in the background.
Just to clarify, I'm not asking how a ListView or an AsyncTask works, but rather for design concepts for my idea.
Thanks in advance.
If I understand correctly what you mean, I think you should try and preload in background the previous and following page, and keep them in memory ready to come in with the swipe.
Every time you change day you would recycle one page of data to load a new one (in one direction or another).
Obviously the user can still swipe too fast and you won't have time to preload things, but in that case I don't think you can do anything better than transitioning in the page with a nice spinner in it (not a blocking dialog).
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.