There is two option in android studio SDK tools for ConstraintLayout.One is ConstraintLayout for android
and another is Solver for ConstraintLayout
.
Here is the screenshot:
What is the difference between these two option?
ConstraintLayout has dual power of both Relative Layout as well as Linear layout: Set relative positions of views ( like Relative layout ) and also set weights for dynamic UI (which was only possible in Linear Layout). Despite the fact that it's awesome, it fails to serve the purpose with simple UI layouts.
If you have the choice start with ConstraintLayout, but if you already have your app in RelativeLayout, stay with it. That's all I have been following. RelativeLayout is very limited in functionality and many complex layouts can't be made using it, especially when ratios are involved.
A ConstraintLayout is a ViewGroup which allows you to position and size widgets in a flexible way. Note: ConstraintLayout is available as a support library that you can use on Android systems starting with API level 9 (Gingerbread).
Open the layout file (activity_main. xml) in Android Studio and click the Design tab at the bottom of the editor window. In the Component Tree window, right-click LinearLayout and then choose Convert layout to ConstraintLayout from the context menu.
What Solver Does.
To translate constraints into actual positions and sizes, the constraint solver applies the Cassowary algorithm to find the solution. Look at this Post to know how this kind of layouts work and why solver is there in the package. https://www.bignerdranch.com/blog/constraintlayout-vs-auto-layout-how-do-they-compare/
What exactly is Constraint Layout?
as the android states "A Layout where the positions of the children are described as constraints in relation to each other or to the parent."
https://android.googlesource.com/platform/frameworks/opt/sherpa/+/gradle_2.0.0/constraintlayout/src/main/java/android/support/constraint/ConstraintLayout.java
Constraint Layout is equations describing positional relation between views and Solver solves those equations to help android determine positions (x,y,z, length, width) where views should be drawn.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With