Skip to main content

Posts

Showing posts from October, 2021
Constraint layout Difference between constraint and relative layout Intention of ConstraintLayout is to optimize and flatten the view hierarchy of your layouts by applying some rules to each view to avoid nesting. Rules remind you of RelativeLayout, for example setting the left to the left of some other view. app:layout_constraintBottom_toBottomOf="@+id/view1" Unlike RelativeLayout, ConstraintLayout offers bias value that is used to position a view in terms of 0% and 100% horizontal and vertical offset relative to the handles (marked with circle). These percentages (and fractions) offer seamless positioning of the view across different screen densities and sizes. app:layout_constraintHorizontal_bias="0.33" app:layout_constraintVertical_bias="0.53"
View holder pattern Why view holder pattern is important? As you fling through your ListView, there's only a handful of views being shown at any given time. This means that you don't have to instantiate a view for every item in your adapter; when a view scrolls off-screen, it can be reused, or recycled. View recycling and the ViewHolder pattern are not the same. The ViewHolder pattern is solely to reduce the number of view.findViewById(int) calls you make. The ViewHolder pattern only works when you take advantage of view recycling. In getView(int position, View convertView, ViewGroup parent), the convertView parameter is either null or it's a view that has been recycled: it will still have the data from a different list item bound to it. Without the ViewHolder pattern, you can still take advantage of view recycling (i.e. not blindly instantiating views):
Android vitals What are android vitals? The dashboard highlights crash rate, ANR rate , excessive wakeup , and stuck wake locks : these are the core vitals developers should give attention to. All other vitals, when applicable to your type of app or game, should be monitored to ensure they aren't having a negative effect. Exhibiting bad behavior in vitals will negatively affect the user experience in your app and is likely to result in bad ratings and poor discoverability on the Play Store. Excessive background Wi-Fi scans Excessive background network usage App startup time Slow rendering Frozen frames Permission denials
UI thread and backgound thread.. UI thread in Android When an app icon is clicked to launch it, system starts a new process and runs the main activity on a new thread if the app is not already started. All the subsequent user interactions with the app and components handle the interactions run on the the same thread. This thread is called main thread. If an app is already running on a thread and a component is requested, the component will run on the existing thread for the app. Background or worker thread can be created within the app to run long running tasks. Main thread is also called UI thread as all UI components run on the main thread. But in system apps, UI thread can be different from main thread if views run on different threads.