Skip to main content
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"

Comments

Popular posts from this blog

How will you track foreground and background events in android? Implementing a Foreground and Background Handler First, lets create our interface that will be implemented by a custom Application class. Something as simple as this: interface LifecycleDelegate { fun onAppBackgrounded() fun onAppForegrounded() } we could use onTrimMemory and the TRIM_MEMORY_UI_HIDDEN flag to detect background events. So lets do that now. Add this into the onTrimMemory method callback body if (level == ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) { // lifecycleDelegate instance was passed in on the constructor lifecycleDelegate.onAppBackgrounded() } So now we have the background event covered lets handle the foreground event. To do this we are going to use the onActivityResumed. This method gets called every time any Activity in your app is resumed, so this could be called multiple times if you have multiple Activities. What we will do is use a flag...
Have you ever used Room how to implement room db? Room is an ORM, Object Relational Mapping library. In other words, Room will map our database objects to Java objects. Room provides an abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite. Database : This component represents data holder. The annotated class should be an abstract class that extends RoomDatabase. At runtime, you can acquire an instance of it by calling Room.databaseBuilder() or Room.inMemoryDatabaseBuilder(). DAO : DAOs are the main component of Room and are responsible for defining the methods that access the database. All queries are written in DAO only. IEntity : This component represents a database row of table. Each field of the entity is persisted in the database unless you annotate it with @Ignore . Difference between room and sqlite In case of SQLite, There is no compile tim...