Android does a lot of things to show what you are seeing on the screen. What users are seeing is code. Code talk to different system hardware and libraries to make things what it should look like on the screen.
The challenges aren’t any less of the same. Android apps are designed to run at 60 FPS but are the apps running at FPS? What it means not to render at FPS.
Before we jump into the problems and possible solutions. We might have to understand what happens under the hood.
Creating a smooth and responsive UI isn’t an easy task with Android considering the amount of height / Width / Pixels and processing power to play with. There are different stages in the app that needs to be optimized. For example, The layouts in your app are extremely optimized to run on different screen sizes but when you are requesting for a data from the server or it gets worse when the network is slow, the apps end up loading for a while.
Rendering 60 FPS means that the users will not see any frame drops and will be smooth. This experience is often not felt in Android & called dropped frames. Any rendering that takes more than 16 ms for a frame to draw is dropped frames.
Optimizing App launch time
App often does a lot of things while an app is launched. To avoid displaying an empty screen, Android introduced “Splash screen” to let users know that the app is being prepared for users to interact with. This often is not being followed by many apps.
This is the most important part of an app that is directly in contact with the users. Layouts lead not just a bad User experience but also the apps memory hungry.
Here are some quick ideas that can be embedded into the process while developing an android app for UI performance.
– Initializing objects that are necessary for the start. For example, singleton design pattern saves memory since the objects are not created at each request, the same request is reused again for quick recovery
– UI hierarchy – Nested layouts are culprits of memory hungry apps, linear layouts are straight forward. However nesting several linear layouts can also be expensive. Flattening the UI is recommended for better performance
– Fewer images and user vector shapes – Android recommends using 9 patches which Android can adapt to for various resolutions and screen dimensions. If the same icon is used on different screens with different colors, adding multiple images is just increases the complexity. Using android: tint helps to adapt to the primary colors
– Don’t reinvent the wheel – Use default design elements of Android in Android Studio for navigations & action bars.
– User caching libraries – Some of the libraries by Google for client side caching such as Glide for image processing is are great libraries for caching lot of resources of the app for faster rendering.