Differences between ConstraintLayout and RelativeLayout –

Development issue/problem:

I’m not sure what the difference is between the coercive method and the relative method. Can somebody tell me how they’re different?

How can this problem be solved?

Decision No 1:

The aim of ConstraintLayout is to optimize and align the hierarchy of classification views by applying certain rules to each view to prevent nesting.

The rules are reminiscent of those of RelativeLayout, for example a left-handed installation of a different type.

app:layout_constraintBottom_toBottomOf=@+id/view1

Unlike the RelativeLayout, the ConstraintLayout offers an offset value that is used to position the view as a horizontal and vertical offset of 0% and 100% of the handles (marked with a circle). With these percentages (and fractions) the image can be positioned transparently on a screen of different density and size.

app:layout_restrictionHorizontal_preload=0.33
app:layout_restrictionVertical_preload=0.53

The basic handle (long tube with rounded corners, underneath the round handle) is used to align the contents of the view with another view reference.

Square descriptors (in each corner of the view) are used to change the size of the view in dps.

This is entirely based on my opinion and impression of ConstraintLayout.

Decision No 2:

Equivalent properties for relative classification and limitation of classification

(1 ) Scheme on :

android: layout_centerInParent=true

(1 ) Corresponds to a restricted facility:

app:layout_constraintBottomOf=Higher
app:layout_constraintLeft_toLeftOf=Higher
app:layout_constraintStart_toStartOf=Higher
app:layout_constraintRight_toRightOf=Chapter
app:layout_constraintEnd_toEndOf=Chapter
app:layout_constraintTop_toTopOf=chapter

(2 ) Scheme on :

android: layout_centerHorizontal=true

(2) Corresponds to a discrete classification:

app:layout_constraintLeft_toLeftOf=higherapp:layout_constraintStart_toStartOf=higherapp:layout_constraintRight_toRightOf=higherapp:layout_constraintEnd_toEndOf=higherapp:layout_constraintEnd_toEndOf=higherapp:layout_constraintEnd_toEndOf=higherapp

(3 ) Scheme on :

android: layout_centerVertical=true

(3) Corresponds to a discrete classification:

app:layout_constraintBottom_toBottomOf=top
app:layout_constraintTop_toTopOf=top

(4 ) Scheme on :

android: layout_alignParentLeft=true

(4) Corresponds to a discrete classification:

app:layout_constraintLeft_toLeftOf=parent

(5 ) Scheme on :

android: layout_alignParentStart=true

(5) Corresponds to a discrete classification:

app:layout_constraintStartOf=higher

(6 ) Scheme on :

android: layout_alignParentRight=true

(6) Corresponds to a discrete classification:

app:layout_constraintRight_toRightOf=parent

(7 ) Scheme on :

android: layout_alignParentEnd=true

(7) Corresponds to a discrete classification:

app:layout_constraintEnd_toEndOf=higher

(8 ) Scheme on :

android: layout_alignParentTop=true

(8) Corresponds to a discrete layout :

app:layout_constraintTop_toTopOf= higher

(9 ) Scheme on :

android: layout_alignParentBottom=true

(9) Corresponds to a discrete classification:

app:layout_constraintBottom_toBottomOf=parent

(10 ) Scheme on :

android: layout_alignStart=@id/view

(10) Corresponds to a discrete classification:

app:layout_constraintStartOf=@id/view

(11 ) Scheme on :

android: layout_alignLeft=@id/view

(11 ) Corresponds to a discrete classification:

app:layout_constraintLeft_toLeftOf=@id/view

(12 ) Scheme on :

android: layout_alignEnd=@id/view

(12 ) Corresponds to a discrete classification:

app:layout_constraintEnd_toEndOf=@id/view

(13 ) Scheme on :

android: layout_alignRight=@id/view

(13 ) Corresponds to a discrete classification:

app:layout_constraintRight_toRightOf=@id/view

(14 ) Scheme on :

android: layout_alignTop=@id/view

(14 ) Corresponds to a discrete classification:

app:layout_constraintTop_toTopOf=@id/view

(15 ) Scheme on :

android: layout_alignBaseline=@id/view

(15 ) Corresponds to a discrete classification:

app:layout_constraintBaseline_toBaselineOf=@id/view

(16 ) Scheme on :

android: layout_alignBottom=@id/view

(16 ) Corresponds to a discrete classification:

app:layout_constraintBottom_toBottomOf=@id/view

(17 ) Scheme on :

android: layout_toStartOf=@id/view

(17 ) Corresponds to a discrete classification:

app:layout_constraintEnd_toStartOf=@id/view

(18 ) Scheme on :

android: layout_toLeftOf=@id/view

(18 ) Corresponds to a discrete classification:

app:layout_constraintRight_toLeftOf=@id/view

(19 ) Scheme on :

android: layout_toEndOf=@id/view

(19 ) Corresponds to a discrete classification:

app:layout_constraintStart_toEndOf=@id/view

(20 ) Scheme on :

android: layout_toRightOf=@id/view

(20 ) Corresponds to a discrete classification:

app:layout_constraintLeft_toRightOf=@id/view

(21 ) Scheme on :

android: layout_above=@id/view

(21 ) Corresponds to a discrete classification:

app:layout_constraintBottom_toTopOf=@id/view

(22 ) Scheme on :

android: layout_below=@id/view

(22 ) Corresponds to a discrete classification:

app:layout_constraintTop_toBottomOf=@id/view

Decision No 3:

Reported performance @davidpbr ConstraintLayout

I made two identical models with 7 children, one with ConstraintLayout and RelativeLayout parents.
According to the Android Studio plotting tool it appears that ConstraintLayout spends more time on OnMeasure and does extra work on FinishInflate.

Library used (support – v4, appcompat-v7…) :

com.android.support.constraint: constraraint-layout: 1.0.0-alpha1

The Android devices/versions you play on:
Samsung Galaxy S6 (SM-G920A. Sorry, no Nexus distributor). Android 5.0.2

Quick comparison of search methods :

Example of a Github repo: https://github.com/OnlyInAmerica/ConstraintLayoutPerf.

Decision No 4:

The differences/benefits are listed below:

  1. The voltage control has twice the power of the relative and linear control: Define the relative positions of the views (e.g. relative layouts) and also set the weights for the dynamic user interface (this was only possible in a linear layout).
  2. A very powerful application is the grouping of elements that form a chain. In this way we can form a view group that can be placed in any way we want without adding another hierarchical level to form another view group.
  3. In addition to the weights, it is possible to use a horizontal and vertical shift that is no more than a percentage of the shift from the centre. (An offset of 0.5 means central alignment. Any smaller or larger value means the corresponding movement in the corresponding direction) .
  4. Another very important function is to record and make available functions for working with GONE views, so that layouts are not interrupted when a view is set to GONE via Java code. More information can be found here:
    https://developer.android.com/reference/android/support/constraint/ConstraintLayout.html#VisibilityBehavior.
  5. Enables automatic restrictions to be applied with the Blue Print and Visual Editing tool, making it easy to design a page.

All these features result in a levelling of the display hierarchy, which improves performance and also contributes to a responsive and dynamic user interface that can be easily adapted to different screen sizes and densities.

The best place to learn fast:
https://codelabs.developers.google.com/codelabs/constraint-layout/#0.

Decision No 5:

The big difference is that ConstraintLayout respects the limitations, even if there is no model. That way the arrangement is not interrupted if you have a necklace and you want the species to disappear in the middle.

Decision No 6:

In addition to the answer @dhaval-jivani.

I updated the github project with the latest version of the layout for limitations in v.1.1.0-beta3.

I measured the time of the onCreate method and compared it with the time between the beginning of the onCreate method and the end of the last preformDraw method, which is visible on the CPU monitor. All tests have been performed on the Samsung S5 mini with Android 6.0.1
. Here are the results:

Restart (first screen that opens after the start of the application)

relative planning

Create: 123ms

Drawing time of the last preform – On time: 311.3ms

Containment plan

OnCreate: 120.3 ms

Drawing time of the last preform – Per hour: 310ms

I also checked the performance test of this article, here is code
and I found that on cycle accounts there are less than 100 restrictions, the layout variant is faster in performing inflation, measurement and layout than variants with relative layout. And on older Android devices such as the Samsung S3 with Android 4.3, the difference is bigger.

Finally, I agree with the comments on the article:

Is it useful to rework the old ideas by changing them from RelativeLayout or LinearLayout?
As always: Depends on
. I won’t charge anything unless you have a performance issue with the current layout hierarchy or you still don’t want to make any major changes to the layout. Although I haven’t measured it lately, I haven’t noticed any performance problems in recent publications. So I think you should use it safely. But – as I said – not just to migrate in the name of migration. Only when it’s necessary and useful.
But for new layouts I almost always use ConstraintLayout. It’s much better than before.

Decision No 7:

A conclusion I can draw.

1) We can design the user interface without touching the xml part of the code, frankly, I have the impression that Google copied the way the user interface was created in iOS applications. This makes sense if you’re familiar with the user interface design in iOS, but in the relative layout it’s difficult to impose restrictions without touching the xml design.

2) Second, unlike other layouts, it has a flat hierarchy of views, which makes it more efficient than the relative layouts you might see in the other answers.

(3) except that it has a relative position, such as a circular relative position, in which we can place another species relative to that species in a certain radius with a certain angle, which cannot be applied in a relative position

Again, the design of the user interface with a restricted layout is the same as the design of the user interface in iOS, so in the future, when you use iOS, it will be easier for you to use a restricted layout.

Decision No 8:

Officially the ConstraintLayout is much faster.

In the version of the Android N class, ConstraintLayout offers similar functionality as RelativeLayout, but for a much lower price.

Decision No 9:

The real question is whether there is any reason to use a provision other than the coercive provision. I think maybe the answer is no.

For those who insist on orienting themselves towards novice programmers and others, they should give a reason why they are inferior to another layout.

Restrictive layouts are better in all respects (they actually cost about 150k in MOTK format). They are faster, simpler, more flexible, they respond better to changes, they solve problems when elements disappear, they adapt better to radically different screen types and they don’t use a nested loop with such a long tree structure for everything. You can place anything you want, anywhere, anytime.

In mid-2016, when the visual layout editor was not good enough, they were a bit bad, but they were so good that if you have a layout, you can seriously consider using layout restrictions, even if it is the same as the RelativeLayout or even a simple LinearLayout. The FrameLaughs clearly still have their raison d’être. But I don’t see any other way to build anything. If they’d started with that, they wouldn’t have added anything else.

Decision No 10:

The only difference I’ve noticed is that things that are installed in a relative drag and drop layout automatically get their size compared to other elements, so when you run the application, you see what you see. However, in the restriction layout, even if you drag an element into the Design View, things can move when you start the application. This can easily be corrected by defining restrictions manually or, more risky, by right-clicking an element in the component structure, selecting the Presentation Constraints submenu and then clicking the Derive Constraints button. I hope this helps.

Good luck!

Related Tags:

premiere rush vs wevideo,premiere rush vs imovie,adobe premiere rush vs pro reddit,premiere rush green screen,premiere rush size,adobe rush resolution,premiere rush vs pro reddit,premiere rush tutorial,premiere rush price,adobe premiere rush vs camtasia,premiere rush keyframe,premiere elements vs pro vs rush,adobe premiere pro 2020 vs 2019,adobe premiere rush — video editor,adobe creative cloud,premiere rush vs davinci resolve,adobe premiere rush price,premiere rush review,adobe premiere rush,premiere pro,adobe premiere pro,is premiere rush free