Skip to main content

Posts

how binding works in android

Why Use Data Binding Every developer wants clean and understandable code, but creating it is easier said than done. People rush, releases come one after another, clients want results and before you know it, your code is a mess. Knowing this, the Android team decided to make things easier by standardizing development. To that end, they launched the Jetpack libraries, which include the Data Binding Library. This library offers several advantages: Less code: By keeping code in activities and fragments small, it helps you write cleaner and more readable code. Fewer errors: The binding is checked at compile time. Faster apps: Since the binding isn’t done in onCreate, your app runs faster. Safer connection between views and code: Because it doesn’t bind at runtime, it’s safer to get the UI components than findViewById(). Safer connection between views and action: Data binding is safer than relying on onClick(), which ca...
Recent posts
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